| From: | Fujii Masao <fujii(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Fix lost wakeups in physical WAL senders |
| Date: | 2026-11-03 01:53:27 |
| Message-ID: | E1xO3iJ-00000001sT6-1zsE@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
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(at)alexspeller(dot)com>
Reviewed-by: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Discussion: https://postgr.es/m/mvx5bs7q.33b99c32-67d8-4373-8611-7a8250fb2fd3@we.are.superhuman.com
Backpatch-through: 16
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/782d9cf8bf823775efb604300713f6c39a5bfb02
Modified Files
--------------
src/backend/replication/walsender.c | 40 +++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Fujii Masao | 2026-11-03 01:53:45 | pgsql: Fix incorrect LSNs in WAL decoding error messages |
| Previous Message | Richard Guo | 2026-11-03 00:52:30 | pgsql: Make Memoize cache keys only of Params from outer query levels |