Wake standby_write/standby_flush waiters from the WAL replay loop
Alexander Korotkov <akorotkov@postgresql.org>
Author:
Alexander Korotkov <akorotkov@postgresql.org>
Date: 2026-05-03T13:22:02Z
Releases:
19 (unreleased)
Wake standby_write/standby_flush waiters from the WAL replay loop The startup process only woke STANDBY_REPLAY waiters after replaying each WAL record. STANDBY_WRITE and STANDBY_FLUSH waiters depended only on walreceiver write/flush callbacks. As a result, replay progress alone did not wake those waiters, and in pure archive recovery (where no walreceiver exists) they could sleep until timeout. Fix by also calling WaitLSNWakeup() for STANDBY_WRITE and STANDBY_FLUSH after each replay. For the replay-floor semantics used by GetCurrentLSNForWaitType(), replay progress is a valid lower bound for both modes: WAL cannot be replayed unless it has already been written and flushed locally. This works together with the replay-position floor in GetCurrentLSNForWaitType(). The getter ensures that a waiter woken by replay can recheck successfully; the replay-side wakeups ensure that a waiter already asleep is notified when replay reaches its target. Reported-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/1957514.1775526774%40sss.pgh.pa.us Author: Xuneng Zhou <xunengzhou@gmail.com> Reviewed-by: Andres Freund <andres@anarazel.de> Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/access/transam/xlogrecovery.c | modified | +8 −2 |
| src/test/recovery/t/049_wait_for_lsn.pl | modified | +64 −0 |
Discussion
- Implement waiting for wal lsn replay: reloaded 154 messages · 2024-11-27 → 2026-07-08