agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
pgsql: Avoid accumulating relation locks during sequence synchronizatio
2+ messages / 1 participants
[nested] [flat]

* pgsql: Avoid accumulating relation locks during sequence synchronizatio
@ 2026-07-29 04:23  Amit Kapila <akapila@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Amit Kapila @ 2026-07-29 04:23 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Avoid accumulating relation locks during sequence synchronization.

While collecting the sequences to synchronize, the sequence sync worker
opened each INIT sequence with RowExclusiveLock and held it until the
transaction committed. With many such sequences, this could exhaust the
shared lock table and fail with "out of shared memory".

The worker only reads each sequence's identity (namespace and name) here
and needs it to stay stable while read, for which AccessShareLock is
enough, as it conflicts with the AccessExclusiveLock taken by DROP,
RENAME, and SET SCHEMA. Take that lock instead and release it as soon as
the identity is read. The later synchronization re-opens each sequence, so
it does not rely on the lock being retained.

Reported-by: Noah Misch <noah@leadboat.com>
Author: vignesh C <vignesh21@gmail.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Backpatch-through: 19, where it was introduced
Discussion: https://postgr.es/m/20260710045217.f0.noahmisch@microsoft.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/c12c101b0846b1e6488f2dc986a852fbc6bf2e3b

Modified Files
--------------
src/backend/replication/logical/sequencesync.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* pgsql: Avoid accumulating relation locks during sequence synchronizatio
@ 2026-07-29 04:23  Amit Kapila <akapila@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Amit Kapila @ 2026-07-29 04:23 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Avoid accumulating relation locks during sequence synchronization.

While collecting the sequences to synchronize, the sequence sync worker
opened each INIT sequence with RowExclusiveLock and held it until the
transaction committed. With many such sequences, this could exhaust the
shared lock table and fail with "out of shared memory".

The worker only reads each sequence's identity (namespace and name) here
and needs it to stay stable while read, for which AccessShareLock is
enough, as it conflicts with the AccessExclusiveLock taken by DROP,
RENAME, and SET SCHEMA. Take that lock instead and release it as soon as
the identity is read. The later synchronization re-opens each sequence, so
it does not rely on the lock being retained.

Reported-by: Noah Misch <noah@leadboat.com>
Author: vignesh C <vignesh21@gmail.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Backpatch-through: 19, where it was introduced
Discussion: https://postgr.es/m/20260710045217.f0.noahmisch@microsoft.com

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/e46c2a65710f021e25bc0fcf404dd00c86aec1d7

Modified Files
--------------
src/backend/replication/logical/sequencesync.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2026-07-29 04:23 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-07-29 04:23 pgsql: Avoid accumulating relation locks during sequence synchronizatio Amit Kapila <akapila@postgresql.org>
2026-07-29 04:23 pgsql: Avoid accumulating relation locks during sequence synchronizatio Amit Kapila <akapila@postgresql.org>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox