pgsql: Take care to de-duplicate entries in standby.c's table of locks.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Take care to de-duplicate entries in standby.c's table of locks.
Дата
Msg-id E1ogTip-001BHB-RN@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/66c2922e76baef07e05763759d2912c0701a5593

Modified Files
--------------
src/backend/storage/ipc/standby.c | 171 +++++++++++++++++++++++---------------
1 file changed, 106 insertions(+), 65 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Introduce t_isalnum() to replace t_isalpha() || t_isdigit() test
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Remove uses of MemoryContextContains in nodeAgg.c and nodeWindow