]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix publisher shutdown hang caused by logical walsender busy loop.
authorFujii Masao <fujii@postgresql.org>
Fri, 6 Mar 2026 07:43:40 +0000 (16:43 +0900)
committerFujii Masao <fujii@postgresql.org>
Fri, 6 Mar 2026 07:44:51 +0000 (16:44 +0900)
commit82935467a0338e0e28acbd357c4c4c7f7aa2aab7
tree9f3b97f67ca8267e69319e05503c16bf03e75724
parentcce939c71c11e9434d96c60977bc805682f3d18d
Fix publisher shutdown hang caused by logical walsender busy loop.

Previously, when logical replication was running, shutting down
the publisher could cause the logical walsender to enter a busy loop
and prevent the publisher from completing shutdown.

During shutdown, the logical walsender waits for all pending WAL
to be written out. However, some WAL records could remain unflushed,
causing the walsender to wait indefinitely.

The issue occurred because the walsender used XLogBackgroundFlush() to
flush pending WAL. This function does not guarantee that all WAL is written.
For example, WAL generated by a transaction without an assigned
transaction ID that aborts might not be flushed.

This commit fixes the bug by making the logical walsender call XLogFlush()
instead, ensuring that all pending WAL is written and preventing
the busy loop during shutdown.

Backpatch to all supported versions.

Author: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>
Reviewed-by: Alexander Lakhin <exclusion@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CAO6_Xqo3co3BuUVEVzkaBVw9LidBgeeQ_2hfxeLMQcXwovB3GQ@mail.gmail.com
Backpatch-through: 14
src/backend/replication/walsender.c