Re: Exit walsender before confirming remote flush in logical replication
Andrey Silitskiy <a.silitskiy@postgrespro.ru>
From: Andrey Silitskiy <a.silitskiy@postgrespro.ru>
To: Vitaly Davydov <v.davydov@postgrespro.ru>,
Fujii Masao <masao.fujii@gmail.com>
Cc: "Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>,
"Takamichi Osumi (Fujitsu)" <osumi.takamichi@fujitsu.com>,
"pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>,
"sawada.mshk@gmail.com" <sawada.mshk@gmail.com>,
"michael@paquier.xyz" <michael@paquier.xyz>,
"peter.eisentraut@enterprisedb.com" <peter.eisentraut@enterprisedb.com>,
"dilipbalaut@gmail.com" <dilipbalaut@gmail.com>,
"andres@anarazel.de" <andres@anarazel.de>,
"amit.kapila16@gmail.com" <amit.kapila16@gmail.com>,
Kyotaro Horiguchi <horikyota.ntt@gmail.com>,
Peter Smith <smithpb2250@gmail.com>, Greg Sabino Mullane
<htamfids@gmail.com>, Alexander Korotkov <aekorotkov@gmail.com>
Date: 2026-01-21T15:11:47Z
Lists: pgsql-hackers
Attachments
- v4-0001-Introduce-a-new-GUC-wal_sender_shutdown_mode.patch (text/x-patch) patch v4-0001
Dear Vitaliy, Thanks for reproducing the error. The problem occurred during a test case with a full output buffer after adding ereport about the termination of walsender process in immediate mode. ereport sends message by default if replica is interested in this logging level(WARNING level fit this description). And since the output buffer was already full, the message could not be sent and the process could not exit. Changed the logging level to LOG_SERVER_ONLY to exclude sending a message to the replica during immediate shutdown. In my environment, this error was not reproduced due to the fact that buffers did not have time to fill up because pg_ctl stop was called immediately after data was inserted and the buffers did not have time to fill up and ereport did not hang. I added a wait for sent_lsn from pg_stat_replication to stop advancing in the test before server shutdown to give walsender time to fill output buffers. Regards, Andrey Silitskiy
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Avoid blocking indefinitely while finishing walsender shutdown
- c0b24b32b0d3 19 (unreleased) landed
-
Add wal_sender_shutdown_timeout GUC to limit shutdown wait for replication
- a8f45dee9176 19 (unreleased) landed
-
pg_upgrade: Add --copy option
- 746915c68669 16.0 cited
-
Prevent possibility of panics during shutdown checkpoint.
- c6c333436491 10.0 cited
-
Support clean switchover.
- 985bd7d49726 9.4.0 cited