postgresql/src/backend
Tom Lane f88bd3139f Don't call palloc() while holding a spinlock, either.
Fix some more violations of the "only straight-line code inside a
spinlock" rule.  These are hazardous not only because they risk
holding the lock for an excessively long time, but because it's
possible for palloc to throw elog(ERROR), leaving a stuck spinlock
behind.

copy_replication_slot() had two separate places that did pallocs
while holding a spinlock.  We can make the code simpler and safer
by copying the whole ReplicationSlot struct into a local variable
while holding the spinlock, and then referencing that copy.
(While that's arguably more cycles than we really need to spend
holding the lock, the struct isn't all that big, and this way seems
far more maintainable than copying fields piecemeal.  Anyway this
is surely much cheaper than a palloc.)  That bug goes back to v12.

InvalidateObsoleteReplicationSlots() not only did a palloc while
holding a spinlock, but for extra sloppiness then leaked the memory
--- probably for the lifetime of the checkpointer process, though
I didn't try to verify that.  Fortunately that silliness is new
in HEAD.

pg_get_replication_slots() had a cosmetic violation of the rule,
in that it only assumed it's safe to call namecpy() while holding
a spinlock.  Still, that's a hazard waiting to bite somebody, and
there were some other cosmetic coding-rule violations in the same
function, so clean it up.  I back-patched this as far as v10; the
code exists before that but it looks different, and this didn't
seem important enough to adapt the patch further back.

Discussion: https://postgr.es/m/20200602.161518.1399689010416646074.horikyota.ntt@gmail.com
2020-06-03 12:36:23 -04:00
..
access Reconsider nbtree page deletion assertion. 2020-05-19 15:04:34 -07:00
bootstrap Skip WAL for new relfilenodes, under wal_level=minimal. 2020-04-04 12:25:34 -07:00
catalog Make pg_stat_wal_receiver consistent with the WAL receiver's shmem info 2020-05-17 09:22:07 +09:00
commands Add missing error code to "cannot attach index ..." error. 2020-05-28 12:37:00 +03:00
executor Mop-up for wait event naming issues. 2020-05-16 21:00:11 -04:00
foreign Update copyrights for 2020 2020-01-01 12:21:45 -05:00
jit llvmjit: Fix building against LLVM 11 by removing unnecessary include. 2020-05-28 15:24:28 -07:00
lib Move src/backend/utils/hash/hashfn.c to src/common 2020-02-27 09:25:41 +05:30
libpq gss: add missing references to hostgssenc and hostnogssenc 2020-05-25 20:19:28 -04:00
main Add PostgreSQL home page to --help output 2020-02-28 13:12:21 +01:00
nodes Reconcile nodes/*funcs.c. 2020-05-25 16:23:48 -07:00
optimizer Use CP_SMALL_TLIST for hash aggregate 2020-05-31 14:43:13 +02:00
parser part_strategy does not need its very own keyword classification. 2020-05-19 20:09:59 -04:00
partitioning Fix two typos in a comment 2020-05-22 17:39:16 -04:00
po Translation updates 2020-05-18 12:49:30 +02:00
port Update copyrights for 2020 2020-01-01 12:21:45 -05:00
postmaster Clear some style deviations. 2020-05-21 08:31:16 -07:00
regex Dial back -Wimplicit-fallthrough to level 3 2020-05-13 15:31:14 -04:00
replication Don't call palloc() while holding a spinlock, either. 2020-06-03 12:36:23 -04:00
rewrite Add missing invocations to object access hooks 2020-05-23 14:03:04 +09:00
snowball Update copyrights for 2020 2020-01-01 12:21:45 -05:00
statistics Run pgindent with new pg_bsd_indent version 2.1.1. 2020-05-16 11:54:51 -04:00
storage Use correct and consistent unit abbreviation 2020-06-01 21:18:36 +02:00
tcop Initial pgindent and pgperltidy run for v13. 2020-05-14 13:06:50 -04:00
tsearch Further cleanup of ts_headline code. 2020-04-09 15:38:43 -04:00
utils Fix use-after-release mistake in currtid() and currtid2() for views 2020-06-01 14:41:18 +09:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
Makefile Update copyrights for 2020 2020-01-01 12:21:45 -05:00
nls.mk Add missing gettext triggers 2020-04-28 13:35:40 +02:00