pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alexander Korotkov <akorotkov@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix WaitLSNWakeup() fast-path check for InvalidXLogRecPtr
Date: Sat, 15 Nov 2025 10:28:03 +0000
Message-ID: <E1vKDVj-006iAd-12@gemulon.postgresql.org> (raw)

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 <xunengzhou@gmail.com>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/ede6acef49673df0a880edae405ca69393bb48d0

Modified Files
--------------
src/backend/access/transam/xlogwait.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)



Message-ID: <E1vKDVj-006iAd-12@gemulon.postgresql.org>
Permalink:  ../E1vKDVj-006iAd-12@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1vKDVj-006iAd-12@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: akorotkov@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix WaitLSNWakeup() fast-path check for InvalidXLogRecPtr
  In-Reply-To: <E1vKDVj-006iAd-12@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox