Fix WaitLSNWakeup() fast-path check for InvalidXLogRecPtr
authorAlexander Korotkov <[email protected]>
Sat, 15 Nov 2025 10:16:23 +0000 (12:16 +0200)
committerAlexander Korotkov <[email protected]>
Sat, 15 Nov 2025 10:27:42 +0000 (12:27 +0200)
commitede6acef49673df0a880edae405ca69393bb48d0
tree9ab68b880055dac42f4d441a1ed6089ba88011b8
parent446568c22207795da02e26b6b2956a61bd17e912
Fix WaitLSNWakeup() fast-path check for InvalidXLogRecPtr

WaitLSNWakeup() incorrectly returned early when called with
InvalidXLogRecPtr (meaning "wake all waiters"), because the fast-path
check compared minWaitedLSN > 0 without validating currentLSN first.
This caused WAIT FOR LSN commands to wait indefinitely during standby
promotion until random signals woke them.

Add an XLogRecPtrIsValid() check before the comparison so that
InvalidXLogRecPtr bypasses the fast-path and wakes all waiters immediately.

Discussion: https://postgr.es/m/CABPTF7UieOYbOgH3EnQCasaqcT1T4N6V2wammwrWCohQTnD_Lw%40mail.gmail.com
Author: Xuneng Zhou <[email protected]>
Reviewed-by: Alexander Korotkov <[email protected]>
src/backend/access/transam/xlogwait.c