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
v2-0001-Don-t-wait-for-LogicalDecodingControlLock-in-the-.patch
Description: v2-0001-Don-t-wait-for-LogicalDecodingControlLock-in-the-.patch
v2-0002-Add-a-test-for-the-postmaster-waiting-on-LogicalD.patch
Description: v2-0002-Add-a-test-for-the-postmaster-waiting-on-LogicalD.patch
