pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix lost wakeups in logical WAL senders
5+ messages / 1 participants
[nested] [flat]

* pgsql: Fix lost wakeups in logical WAL senders
@ 2026-11-25 07:16  Fujii Masao <fujii@postgresql.org>
  0 siblings, 0 replies; 5+ messages in thread

From: Fujii Masao @ 2026-11-25 07:16 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix lost wakeups in logical WAL senders

Logical WAL senders could sleep even when WAL was available for
decoding, delaying logical replication until another event woke them.
When synchronous logical replication is configured, this could also
delay commits waiting for acknowledgment from the subscriber.

Commit bc971f4025c changed WAL sender wakeups to use condition
variables, which notify only senders already on the waitlist.
However, WalSndWaitForWal() checks the flush position on a primary,
or the replay position on a standby, before WalSndWait() joins the
waitlist. If the required WAL becomes available between these two
steps, the wakeup can be missed, leaving the sender asleep despite
having enough WAL to continue decoding.

Fix this by passing the required WAL position to WalSndWait() and
rechecking the flush or replay position after joining the waitlist.
If enough WAL is available, return to WalSndWaitForWal() to reevaluate
its conditions, including any need to wait for standby confirmation.
This allows decoding to proceed without waiting for another wakeup
when the required WAL became available before waitlist registration,
avoiding the resulting replication and synchronous commit delays.

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

Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.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/bc85373ff1344c03abf0d74e698b3631936ca3c7

Modified Files
--------------
src/backend/replication/walsender.c | 43 +++++++++++++++++++++++++++++++------
1 file changed, 37 insertions(+), 6 deletions(-)



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* pgsql: Fix lost wakeups in logical WAL senders
@ 2026-11-25 07:16  Fujii Masao <fujii@postgresql.org>
  0 siblings, 0 replies; 5+ messages in thread

From: Fujii Masao @ 2026-11-25 07:16 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix lost wakeups in logical WAL senders

Logical WAL senders could sleep even when WAL was available for
decoding, delaying logical replication until another event woke them.
When synchronous logical replication is configured, this could also
delay commits waiting for acknowledgment from the subscriber.

Commit bc971f4025c changed WAL sender wakeups to use condition
variables, which notify only senders already on the waitlist.
However, WalSndWaitForWal() checks the flush position on a primary,
or the replay position on a standby, before WalSndWait() joins the
waitlist. If the required WAL becomes available between these two
steps, the wakeup can be missed, leaving the sender asleep despite
having enough WAL to continue decoding.

Fix this by passing the required WAL position to WalSndWait() and
rechecking the flush or replay position after joining the waitlist.
If enough WAL is available, return to WalSndWaitForWal() to reevaluate
its conditions, including any need to wait for standby confirmation.
This allows decoding to proceed without waiting for another wakeup
when the required WAL became available before waitlist registration,
avoiding the resulting replication and synchronous commit delays.

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

Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Xuneng Zhou <xunengzhou@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/d10bb70b6232ba3f263ba6b291aa07b52ea28b40

Modified Files
--------------
src/backend/replication/walsender.c | 43 +++++++++++++++++++++++++++++++------
1 file changed, 37 insertions(+), 6 deletions(-)



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* pgsql: Fix lost wakeups in logical WAL senders
@ 2026-11-25 07:16  Fujii Masao <fujii@postgresql.org>
  0 siblings, 0 replies; 5+ messages in thread

From: Fujii Masao @ 2026-11-25 07:16 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix lost wakeups in logical WAL senders

Logical WAL senders could sleep even when WAL was available for
decoding, delaying logical replication until another event woke them.
When synchronous logical replication is configured, this could also
delay commits waiting for acknowledgment from the subscriber.

Commit bc971f4025c changed WAL sender wakeups to use condition
variables, which notify only senders already on the waitlist.
However, WalSndWaitForWal() checks the flush position on a primary,
or the replay position on a standby, before WalSndWait() joins the
waitlist. If the required WAL becomes available between these two
steps, the wakeup can be missed, leaving the sender asleep despite
having enough WAL to continue decoding.

Fix this by passing the required WAL position to WalSndWait() and
rechecking the flush or replay position after joining the waitlist.
If enough WAL is available, return to WalSndWaitForWal() to reevaluate
its conditions, including any need to wait for standby confirmation.
This allows decoding to proceed without waiting for another wakeup
when the required WAL became available before waitlist registration,
avoiding the resulting replication and synchronous commit delays.

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

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

Branch
------
REL_18_STABLE

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

Modified Files
--------------
src/backend/replication/walsender.c | 41 ++++++++++++++++++++++++++++++++-----
1 file changed, 36 insertions(+), 5 deletions(-)



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* pgsql: Fix lost wakeups in logical WAL senders
@ 2026-11-25 07:16  Fujii Masao <fujii@postgresql.org>
  0 siblings, 0 replies; 5+ messages in thread

From: Fujii Masao @ 2026-11-25 07:16 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix lost wakeups in logical WAL senders

Logical WAL senders could sleep even when WAL was available for
decoding, delaying logical replication until another event woke them.
When synchronous logical replication is configured, this could also
delay commits waiting for acknowledgment from the subscriber.

Commit bc971f4025c changed WAL sender wakeups to use condition
variables, which notify only senders already on the waitlist.
However, WalSndWaitForWal() checks the flush position on a primary,
or the replay position on a standby, before WalSndWait() joins the
waitlist. If the required WAL becomes available between these two
steps, the wakeup can be missed, leaving the sender asleep despite
having enough WAL to continue decoding.

Fix this by passing the required WAL position to WalSndWait() and
rechecking the flush or replay position after joining the waitlist.
If enough WAL is available, return to WalSndWaitForWal() to reevaluate
its conditions, including any need to wait for standby confirmation.
This allows decoding to proceed without waiting for another wakeup
when the required WAL became available before waitlist registration,
avoiding the resulting replication and synchronous commit delays.

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

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

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/212624da5ba1b6aa4794deb62d00c7e8a0912fc4

Modified Files
--------------
src/backend/replication/walsender.c | 41 ++++++++++++++++++++++++++++++++-----
1 file changed, 36 insertions(+), 5 deletions(-)



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* pgsql: Fix lost wakeups in logical WAL senders
@ 2026-11-25 07:16  Fujii Masao <fujii@postgresql.org>
  0 siblings, 0 replies; 5+ messages in thread

From: Fujii Masao @ 2026-11-25 07:16 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix lost wakeups in logical WAL senders

Logical WAL senders could sleep even when WAL was available for
decoding, delaying logical replication until another event woke them.
When synchronous logical replication is configured, this could also
delay commits waiting for acknowledgment from the subscriber.

Commit bc971f4025c changed WAL sender wakeups to use condition
variables, which notify only senders already on the waitlist.
However, WalSndWaitForWal() checks the flush position on a primary,
or the replay position on a standby, before WalSndWait() joins the
waitlist. If the required WAL becomes available between these two
steps, the wakeup can be missed, leaving the sender asleep despite
having enough WAL to continue decoding.

Fix this by passing the required WAL position to WalSndWait() and
rechecking the flush or replay position after joining the waitlist.
If enough WAL is available, return to WalSndWaitForWal() to reevaluate
its conditions, including any need to wait for standby confirmation.
This allows decoding to proceed without waiting for another wakeup
when the required WAL became available before waitlist registration,
avoiding the resulting replication and synchronous commit delays.

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

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

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/2161e1732f5a4113f0b21e2dbc9ed0b86fb3e07e

Modified Files
--------------
src/backend/replication/walsender.c | 42 ++++++++++++++++++++++++++++++++-----
1 file changed, 37 insertions(+), 5 deletions(-)



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2026-11-25 07:16 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-25 07:16 pgsql: Fix lost wakeups in logical WAL senders Fujii Masao <fujii@postgresql.org>
2026-11-25 07:16 pgsql: Fix lost wakeups in logical WAL senders Fujii Masao <fujii@postgresql.org>
2026-11-25 07:16 pgsql: Fix lost wakeups in logical WAL senders Fujii Masao <fujii@postgresql.org>
2026-11-25 07:16 pgsql: Fix lost wakeups in logical WAL senders Fujii Masao <fujii@postgresql.org>
2026-11-25 07:16 pgsql: Fix lost wakeups in logical WAL senders Fujii Masao <fujii@postgresql.org>

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