| From: | "T, Adesh" <adeshdb(at)amazon(dot)com> |
|---|---|
| To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Cc: | Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> |
| Subject: | Postmaster PANIC on a standby with slot synchronization enabled |
| Date: | 2026-11-20 22:46:07 |
| Message-ID: | SACPR18MB289161635AF5E3E805B1E19EE8DE782@SACPR18MB289161.namprd18.prod.outlook.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
On a standby with slot synchronization enabled, the postmaster can PANIC
with "cannot wait without a PGPROC structure" and exit, taking the whole
server down. While no slot sync worker is running, the postmaster checks
on every wakeup whether logical decoding is enabled. Since 67c20979ce7,
which turns logical decoding on when the first logical slot is created,
that check takes an LWLock. If the startup process holds that lock
exclusively while it replays a logical decoding status change, the
postmaster has to wait, and it can't wait without a PGPROC. The window is
narrow, but it is easy to hit with a debugger or an injection point, and
it reproduces on current master.
The attached 0001 has the postmaster read the flag without the lock. It is
a single bool, and a locked read would not stay valid until the worker
starts anyway. To cover a stale read, the slot sync worker checks again
under the lock when it starts and exits if logical decoding is off, which
costs at most one extra worker start. Other options would be to make the
flag an atomic in shared memory, or to drop the check from the postmaster
and let the worker decide. 0002 adds an injection point and a TAP test
that reproduces the PANIC; it is not for commit. The fix needs to be
backpatched to v19.
Thanks,
Adesh Thakare
| Attachment | Content-Type | Size |
|---|---|---|
| v2-0001-Don-t-wait-for-LogicalDecodingControlLock-in-the-.patch | application/octet-stream | 3.0 KB |
| v2-0002-Add-a-test-for-the-postmaster-waiting-on-LogicalD.patch | application/octet-stream | 6.4 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Zsolt Parragi | 2026-11-20 22:47:23 | Re: EXPLAIN ANALYZE CREATE TABLE AS EXECUTE runs non-SELECT prepared statements |
| Previous Message | Michael Paquier | 2026-11-20 22:34:36 | Re: Checkpoints stuck after a failed bulk write inside a savepoint |