| From: | vignesh C <vignesh21(at)gmail(dot)com> |
|---|---|
| To: | Noah Misch <noah(at)leadboat(dot)com> |
| Cc: | amit(dot)kapila16(at)gmail(dot)com, pgsql-hackers(at)postgresql(dot)org |
| Subject: | Re: sequencesync worker race with REFRESH SEQUENCES |
| Date: | 2026-07-28 07:02:48 |
| Message-ID: | CALDaNm1jzTXoqXWbnpcOuS7PM-bAFLswcya5fvpqp=H9Y6xEGg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Fri, 10 Jul 2026 at 10:22, Noah Misch <noah(at)leadboat(dot)com> wrote:
>
> The other findings are gray areas, perhaps.
I analyzed finding 4: "Gathering scan holds a lock on every INIT
relation in one unbounded transaction."
The sequence synchronization worker acquires a RowExclusiveLock on
every INIT sequence while scanning pg_subscription_rel and retains
those locks until the transaction commits. On subscriptions with a
large number of INIT sequences, this can exhaust the shared lock
table, causing repeated "out of shared memory" failures. The attached
v1-0001 patch addresses this by releasing the lock immediately after
synchronizing each sequence, preventing lock accumulation. It also
acquires an AccessShareLock instead of a RowExclusiveLock, since
AccessShareLock is sufficient to ensure that the sequence's identity
(namespace and name) remains stable against concurrent DROP, RENAME,
and SET SCHEMA operations while the sequence is being synchronized.
The attached v1-0002 patch contains a TAP test that reproduces the
issue on HEAD. I'm attaching it in case anyone wants to reproduce the
problem locally, although I don't think this test needs to be
committed.
Regards,
Vignesh
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Avoid-accumulating-relation-locks-during-sequence.patch | application/octet-stream | 2.4 KB |
| v1-0002-Add-a-TAP-test-to-reproduce-sequence-sync-lock-ta.patch | application/octet-stream | 6.5 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jakub Wartak | 2026-07-28 07:04:16 | Re: aio tests failing on newer Linux kernels |
| Previous Message | Alberto Piai | 2026-07-28 06:50:55 | Re: tablecmds: fix bug where index rebuild loses replica identity on partitions |