postgresql/src/backend
Tom Lane 66c2922e76 Take care to de-duplicate entries in standby.c's table of locks.
The RecoveryLockLists data structure, which tracks all exclusive
locks that the startup process is holding on behalf of transactions
being replayed, did not have any provision for avoiding duplicate
entries for the same lock.  Maybe that was okay when the code was
first written.  However, modern practice is for checkpoints to
write fresh lists of all active exclusive locks into the WAL.
Thus, an exclusive lock that survives across multiple checkpoints
causes bloat in standbys' startup processes.  If there are a lot
of such locks this can look like a memory leak, and it's even
possible to drive the startup process into a palloc failure from
an over-length List.

To fix, use a hash table instead of simple lists to track the
locks being held.  Allowing for dynahash overhead, this requires
a little more space per lock than the old way (although it's the
same size as what we were allocating prior to c6e0fe1f2).  It's
probably a shade slower too.  However, testing indicates that the
penalty is negligible on ordinary workloads, so let's make this
change to improve robustness in extreme cases.

Patch by me, per report from Dmitriy Kuzmin.  No back-patch
(for now anyway), since it seems that a significant improvement
would only occur in corner cases.

Discussion: https://postgr.es/m/CAHLDt=_ts0A7Agn=hCpUh+RCFkxd+G6uuT=kcTfqFtGur0dp=A@mail.gmail.com
2022-10-06 12:27:36 -04:00
..
access Fix comment in xlogprefetcher.c 2022-10-06 20:25:02 +09:00
backup Rename shadowed local variables 2022-10-05 21:01:41 +13:00
bootstrap meson: Add initial version of meson based build system 2022-09-21 22:37:17 -07:00
catalog Rename shadowed local variables 2022-10-05 21:01:41 +13:00
commands Rename shadowed local variables 2022-10-05 21:01:41 +13:00
executor Rename shadowed local variables 2022-10-05 21:01:41 +13:00
foreign meson: Add initial version of meson based build system 2022-09-21 22:37:17 -07:00
jit meson: Add windows resource files 2022-10-05 09:56:05 -07:00
lib meson: Add initial version of meson based build system 2022-09-21 22:37:17 -07:00
libpq meson: Add initial version of meson based build system 2022-09-21 22:37:17 -07:00
main meson: Add initial version of meson based build system 2022-09-21 22:37:17 -07:00
nodes Revert 56-bit relfilenode change and follow-up commits. 2022-09-28 09:55:28 -04:00
optimizer Rename shadowed local variables 2022-10-05 21:01:41 +13:00
parser Rename shadowed local variables 2022-10-05 21:01:41 +13:00
partitioning Rename shadowed local variables 2022-10-05 21:01:41 +13:00
po meson: Add initial version of meson based build system 2022-09-21 22:37:17 -07:00
port meson: Add initial version of meson based build system 2022-09-21 22:37:17 -07:00
postmaster Message style improvements 2022-09-24 18:41:25 -04:00
regex Remove uses of register due to incompatibility with C++17 and up 2022-09-24 12:08:37 -07:00
replication meson: Add windows resource files 2022-10-05 09:56:05 -07:00
rewrite meson: Add initial version of meson based build system 2022-09-21 22:37:17 -07:00
snowball meson: Add windows resource files 2022-10-05 09:56:05 -07:00
statistics Rename shadowed local variables 2022-10-05 21:01:41 +13:00
storage Take care to de-duplicate entries in standby.c's table of locks. 2022-10-06 12:27:36 -04:00
tcop Add optional parameter to PG_TRY() macros 2022-10-06 10:08:31 +13:00
tsearch Introduce t_isalnum() to replace t_isalpha() || t_isdigit() tests. 2022-10-06 11:08:56 -04:00
utils Introduce t_isalnum() to replace t_isalpha() || t_isdigit() tests. 2022-10-06 11:08:56 -04:00
.gitignore
Makefile Move gramparse.h to src/backend/parser 2022-09-14 10:57:13 +07:00
common.mk Blind attempt to fix LLVM dependency in the backend 2022-09-15 10:53:48 +07:00
meson.build meson: Add initial version of meson based build system 2022-09-21 22:37:17 -07:00
nls.mk NLS: Put list of available languages into LINGUAS files 2022-07-13 08:19:17 +02:00