Remove redundant WAIT FOR LSN caller-side pre-checks
Alexander Korotkov <akorotkov@postgresql.org>
Author:
Alexander Korotkov <akorotkov@postgresql.org>
Date: 2026-05-03T13:22:02Z
Releases:
19 (unreleased)
Remove redundant WAIT FOR LSN caller-side pre-checks All five wakeup call sites duplicate WaitLSNWakeup()'s internal fast-path minWaitedLSN check and add an unnecessary NULL check on waitLSNState. Remove the inline pre-checks and call WaitLSNWakeup() directly. The fast-path check inside WaitLSNWakeup() already returns early when no waiter's target has been reached, so there is no performance difference. The waitLSNState NULL checks are also unnecessary: shared memory is fully initialized before any backend or auxiliary process starts, so waitLSNState is always non-NULL at these call sites. Reported-by: Andres Freund <andres@anarazel.de> Discussion: https://postgr.es/m/jzq5shdewncpxc35r3s2mcfsmo4bjovkza5mnqf5bdfumhfi3g%40bglckf7dxmw5 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/xlog.c | modified | +6 −10 |
| src/backend/access/transam/xlogrecovery.c | modified | +4 −7 |
| src/backend/replication/walreceiver.c | modified | +6 −11 |
Discussion
- Implement waiting for wal lsn replay: reloaded 154 messages · 2024-11-27 → 2026-07-08