Wake primary_flush waiters after implicit WAL flushes XLogWrite() can advance the flush position when it finishes a WAL segment, even if its caller requested only a write. When this happens while AdvanceXLInsertBuffer() recycles a buffer, primary_flush waiters are not notified and can sleep until an unrelated flush or checkpoint.
Track such progress with a process-local pending flag and perform the wakeup after releasing WAL write and insertion locks, keeping WaitLSNLock acquisition outside the contended WAL path. Add a deterministic injection-point test that forces this path and inspects the registration directly in shared memory. Author: Xuneng Zhou <[email protected]> Discussion: https://postgr.es/m/CABPTF7U0gW5%2B-4oL7-qdML-yerZxUb7ku4QXp7JxCYo0qyJ_Tw%40mail.gmail.com Reviewed-by: Alexander Korotkov <[email protected]> Backpatch-through: 19 Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/854be98cc4aad48a960197e4d70b1da9063a906e Modified Files -------------- src/backend/access/transam/xlog.c | 34 ++++++++ src/backend/access/transam/xlogwait.c | 3 + src/backend/postmaster/walwriter.c | 3 + src/test/recovery/t/049_wait_for_lsn.pl | 146 ++++++++++++++++++++++++++++++++ 4 files changed, 186 insertions(+)
