Re: Exit walsender before confirming remote flush in logical replication
Fujii Masao <masao.fujii@gmail.com>
From: Fujii Masao <masao.fujii@gmail.com>
To: Andrey Silitskiy <a.silitskiy@postgrespro.ru>
Cc: Greg Sabino Mullane <htamfids@gmail.com>, Japin Li <japinli@hotmail.com>, Ronan Dunklau <ronan@dunklau.fr>, Vitaly Davydov <v.davydov@postgrespro.ru>, "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>,
Alexander Korotkov <aekorotkov@gmail.com>
Date: 2026-03-25T12:39:00Z
Lists: pgsql-hackers
On Mon, Mar 16, 2026 at 5:52 AM Andrey Silitskiy <a.silitskiy@postgrespro.ru> wrote: > > On Fri, 13 Mar 2026 Greg Sabino Mullane <htamfids(at)gmail(dot)com> wrote: > > +1. I don't think we need to measure any times, but we do need to > > exercise that whole part of the code, ... > > Added a case with a positive but small wal_sender_shutdown_timeout > to the test. Thanks for updating the patch! I tested wal_sender_shutdown_timeout under several configurations and encountered a case where the primary shutdown got stuck, even with the patch and wal_sender_shutdown_timeout = 1. I'm not sure yet whether this is a bug in the patch or an issue with my test setup, but anyway I'd like to share the reproduction steps for reference. -------------------------------------------------------------------------------- #1. Set up primary, standby (with slot sync), and subscriber initdb -D data --encoding=UTF8 --locale=C cat <<EOF >> data/postgresql.conf wal_level = logical synchronized_standby_slots = 'physical_slot' wal_sender_timeout = 1h wal_sender_shutdown_timeout = 1 log_line_prefix = '%t %p [%b] data ' EOF pg_ctl -D data start pg_receivewal --create-slot -S physical_slot pg_basebackup -D sby1 -c fast -R -S physical_slot -d "dbname=postgres" cat <<EOF >> sby1/postgresql.conf port = 5433 sync_replication_slots = on hot_standby_feedback = on log_line_prefix = '%t %p [%b] sby1 ' EOF pg_ctl -D sby1 start initdb -D sub1 --encoding=UTF8 --locale=C cat <<EOF >> sub1/postgresql.conf port = 5434 wal_level = logical log_line_prefix = '%t %p [%b] sub1 ' EOF pg_ctl -D sub1 start #2. Create table, publication, and subscription psql -p 5432 <<EOF create table t (i int primary key, j int); create publication mypub for table t; EOF psql -p 5434 <<EOF create table t (i int primary key, j int); create subscription mysub connection 'port=5432' publication mypub with (failover = 'on'); EOF #3. Lock the table on the subscriber psql -p 5434 <<EOF begin; lock table t in access exclusive mode; select pg_sleep(1000); EOF #4. Confirm the apply worker is waiting psql -p 5432 -c "insert into t values(1, 0)" psql -p 5434 -c "select * from pg_stat_activity where backend_type like '%apply worker%'" #5. Block walreceiver on the standby by using SIGSTOP signal kill -SIGSTOP $(psql -p 5433 -X -Atc "SELECT pid FROM pg_stat_wal_receiver") #6. Insert another row and shut down the primary psql -p 5432 -c "insert into t values(2, 0)" pg_ctl -D data stop -------------------------------------------------------------------------------- In my tests, the shutdown in step #6 got stuck. Any thoughts on whether this indicates a problem in the patch or something off in my setup? Regards, -- Fujii Masao
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