Re: Implement waiting for wal lsn replay: reloaded
Xuneng Zhou <xunengzhou@gmail.com>
Attachments
- v5-0003-Remove-redundant-WAIT-FOR-LSN-caller-side-pre-che.patch (application/octet-stream) patch v5-0003
- v5-0002-Fix-memory-ordering-in-WAIT-FOR-LSN-wakeup-mechan.patch (application/octet-stream) patch v5-0002
- v5-0005-Wake-standby_write-standby_flush-waiters-from-the.patch (application/octet-stream) patch v5-0005
- v5-0001-Use-barrier-semantics-when-reading-writing-writte.patch (application/octet-stream) patch v5-0001
- v5-0004-Use-replay-position-as-floor-for-WAIT-FOR-LSN-sta.patch (application/octet-stream) patch v5-0004
- v5-0006-Improve-WAIT-FOR-LSN-test-coverage.patch (application/octet-stream) patch v5-0006
- v5-0007-Document-that-WAIT-FOR-LSN-is-timeline-blind.patch (application/octet-stream) patch v5-0007
On Tue, Apr 21, 2026 at 2:46 AM Alexander Korotkov <aekorotkov@gmail.com> wrote: > The updated patchset is attached. It includes improved coverage as > suggested by Andres upthread. And documentation that WAIT FOR LSN is > timeline-blind (per off-list discussion with Xuneng). I revised the test patch 6 to make the new cases check the intended WAIT FOR behavior more directly, and to avoid cases where the test could pass for the wrong reason. The fresh walreceiver restart test now distinguishes what we can observe from what is only covered indirectly. 'pg_last_wal_receive_lsn()' reports 'flushedUpto', not 'writtenUpto', so the test now describes that state accurately and covers 'writtenUpto' through the 'standby_write' result. This seems appropriate to me since the two positions are seeded in the places and conditions. Test for flush lsn should also help verify write lsn. The fencepost tests were split by the actual frontier being tested. 'standby_replay' uses 'pg_last_wal_replay_lsn()', while 'standby_flush' uses 'pg_last_wal_receive_lsn()'. This avoids treating a replay-derived LSN as if it were also the exact write/flush boundary. I left 'standby_write' out of the exact fencepost helper because its frontier is not SQL-visible once walreceiver is stopped. The async wakeup case now starts the waiter while replay is still paused, so it must actually sleep before replay and walreceiver are allowed to advance. The cascading timeline-switch test now checks the 'WAIT FOR ... NO_THROW' status from background psql stdout. The previous log-marker pattern could pass after unexpected returned status, includingn 'timeout', because the following statement would still run. The 'received_tli > 1' check remains, but only as confirmation that the downstream followed the new timeline; the 'success' status proves the wait completed as intended. Please check it. -- Best, Xuneng
Commits
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Clean up 019_replslot_limit.pl comments
- 0b866bb90368 19 (unreleased) landed
-
Stabilize 019_replslot_limit.pl: wait on slot restart_lsn
- cdb1d1cf1de6 19 (unreleased) landed
-
Fix memory ordering in WAIT FOR LSN wakeup mechanism
- a80a593ab636 19 (unreleased) landed
-
Improve WAIT FOR LSN test coverage
- cb096e6d6981 19 (unreleased) landed
-
Remove redundant WAIT FOR LSN caller-side pre-checks
- df9f938ca2ec 19 (unreleased) landed
-
Use barrier semantics when reading/writing writtenUpto
- dfb690dd5237 19 (unreleased) landed
-
Use replay position as floor for WAIT FOR LSN standby_(write|flush)
- cba67b5b87f9 19 (unreleased) landed
-
Wake standby_write/standby_flush waiters from the WAL replay loop
- e7cd592174d9 19 (unreleased) landed
-
Minimal fix for WAIT FOR ... MODE 'standby_flush'
- 29e7dbf5e4da 19 (unreleased) landed
-
Avoid syscache lookup while building a WAIT FOR tuple descriptor
- 834038c1f8d5 19 (unreleased) landed
-
Document that WAIT FOR may be interrupted by recovery conflicts
- 10484c2cc75b 19 (unreleased) landed
-
Use WAIT FOR LSN in PostgreSQL::Test::Cluster::wait_for_catchup()
- 7e8aeb9e483d 19 (unreleased) landed
- f30848cb05d4 19 (unreleased) landed
-
Wake LSN waiters before recovery target stop
- 20a8f783e15c 19 (unreleased) landed
-
Remove redundant pg_unreachable() after elog(ERROR) from ExecWaitStmt()
- 30776ca46865 19 (unreleased) landed
-
Revert "Use WAIT FOR LSN in PostgreSQL::Test::Cluster::wait_for_catchup()"
- e54ce0b2da62 19 (unreleased) landed
-
Fix variable usage in wakeupWaiters()
- bf308639bfcf 19 (unreleased) landed
-
Add tab completion for the WAIT FOR LSN MODE option
- 76948337f724 19 (unreleased) landed
-
Add the MODE option to the WAIT FOR LSN command
- 49a181b5d634 19 (unreleased) landed
-
Extend xlogwait infrastructure with write and flush wait types
- 7a39f43d885b 19 (unreleased) landed
-
Unify error messages
- 502e256f2262 19 (unreleased) cited
-
Optimize shared memory usage for WaitLSNProcInfo
- 75e82b2f5a6f 19 (unreleased) landed
-
Fix WaitLSNWakeup() fast-path check for InvalidXLogRecPtr
- ede6acef4967 19 (unreleased) landed
-
Fix incorrect function name in comments
- 23792d738158 19 (unreleased) landed
-
Add infrastructure for efficient LSN waiting
- 3b4e53a075ea 19 (unreleased) landed
-
Add pairingheap_initialize() for shared memory usage
- 8af3ae0d4b36 19 (unreleased) landed
-
Implement WAIT FOR command
- 447aae13b030 19 (unreleased) landed