pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Fujii Masao <fujii@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix lost wakeups in physical WAL senders
Date: Tue, 03 Nov 2026 01:53:45 +0000
Message-ID: <E1xO3ib-00000001sUX-0RBe@gemulon.postgresql.org> (raw)

Fix lost wakeups in physical WAL senders

Physical WAL senders could sleep even when flushed WAL was waiting to
be sent, delaying replication and synchronous commits until another
event woke them. In the reported case, commits stalled for about ten
seconds, until the standby sent its next periodic status report.

Commit bc971f4025c changed WAL sender wakeups to use condition
variables, which notify only senders already on the waitlist.
However, XLogSendPhysical() checks the flush position before
WalSndWait() joins the waitlist. If WAL is flushed between these two
steps, the wakeup can be missed, leaving the sender asleep despite
having more WAL to send.

Fix this by rechecking the flush position after joining the waitlist
and returning to the send loop if more WAL is available. For cascading
senders, also check for promotion or a timeline change, which require
the sender to revisit the current timeline even if the flush position
has not advanced.

Backpatch to v16, where commit bc971f4025c introduced the
condition-variable wakeup mechanism.

Author: Alex Speller <alex@alexspeller.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/mvx5bs7q.33b99c32-67d8-4373-8611-7a8250fb2fd3@we.are.superhuman.com
Backpatch-through: 16

Branch
------
REL_19_STABLE

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

Modified Files
--------------
src/backend/replication/walsender.c | 40 +++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)



view thread (5+ messages)  latest in thread

Message-ID: <E1xO3ib-00000001sUX-0RBe@gemulon.postgresql.org>
Permalink:  ../E1xO3ib-00000001sUX-0RBe@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xO3ib-00000001sUX-0RBe@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: fujii@postgresql.org
  Subject: Re: pgsql: Fix lost wakeups in physical WAL senders
  In-Reply-To: <E1xO3ib-00000001sUX-0RBe@gemulon.postgresql.org>
  References: <E1xO3ib-00000001sUX-0RBe@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