Re: Use SIGTERM instead of SIGUSR1 for slotsync worker to exit during promotion?
Fujii Masao <masao.fujii@gmail.com>
From: Fujii Masao <masao.fujii@gmail.com>
To: shveta malik <shveta.malik@gmail.com>
Cc: Nisha Moond <nisha.moond412@gmail.com>,
Amit Kapila <amit.kapila16@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-03-31T15:33:27Z
Lists: pgsql-hackers
On Tue, Mar 31, 2026 at 7:42 PM shveta malik <shveta.malik@gmail.com> wrote: > > > One idea would be to prevent the restart altogether. For example, > > > ProcessSlotSyncMessage() could set SlotSyncCtx->last_start_time to > > > a special value (like -1), and SlotSyncWorkerCanRestart() could return > > > false (i.e., prevent postmater from starting up slotsync worker) when > > > it sees that. Alternatively, SlotSyncWorkerCanRestart() could simply > > > check SlotSyncCtx->stopSignaled. > > > > > > That said, as far as I remember correctly, postmaster is generally not > > > supposed to touch shared memory (per the comments in postmaster.c), > > > so I'm not sure this approach is acceptable. On the other hand, > > > postmaster and the slotsync worker already rely on SlotSyncCtx->last_start_time, > > > so perhaps there's some precedent here. > > > > > IIUC, checking SlotSyncCtx->stopSignaled in SlotSyncWorkerCanRestart() > > may not be ideal, as it requires a spinlock to avoid races with the > > startup process and it is disallowed to take lock in postmaster main > > loop. Whereas, SlotSyncCtx->last_start_time doesn’t need a lock since > > the postmaster accesses it only when the worker is not alive. > > > > I agree. Could you clarify what issue might arise from checking SlotSyncCtx->stopSignaled without holding a spinlock in SlotSyncWorkerCanRestart()? Is it actually problematic? That said, since the postmaster should generally avoid touching shared memory, it doesn't seem like a good idea for it to check SlotSyncCtx->stopSignaled. So I'm fine with instead lowering the log level for the "worker will not start" message to DEBUG1. Regards, -- Fujii Masao
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Update .abi-compliance-history for change to enum ProcSignalReason
- 29d8bd908560 17.10 landed
-
Fix ABI break by moving PROCSIG_SLOTSYNC_MESSAGE in ProcSignalReason
- 586f4266fb49 17.10 landed
- acf49bfede2a 18.4 landed
-
Fix slotsync worker blocking promotion when stuck in wait
- 15910b1c363f 17.10 landed
- 58c1188a3eaa 18.4 landed
- db93032a7cbd 19 (unreleased) landed
-
Add retry logic to pg_sync_replication_slots().
- 0d2d4a0ec3ec 19 (unreleased) cited
-
Enhance slot synchronization API to respect promotion signal.
- 1362bc33e025 19 (unreleased) cited