Re: Exit walsender before confirming remote flush in logical replication

Andrey Silitskiy <a.silitskiy@postgrespro.ru>

From: Andrey Silitskiy <a.silitskiy@postgrespro.ru>
To: Greg Sabino Mullane <htamfids@gmail.com>
Cc: 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>, Fujii Masao <masao.fujii@gmail.com>, Alexander Korotkov <aekorotkov@gmail.com>
Date: 2026-03-13T12:00:40Z
Lists: pgsql-hackers

Attachments

Thanks for the review! Fixed patch is attached.

On Wed, 11 Mar 2026 Greg Sabino Mullane <htamfids(at)gmail(dot)com> wrote:
 > I'm not really clear on this - wouldn't we want this only for 
got_SIGUSR2?

Сhecking got_SIGUSR2 alone is not enough. If we received got_STOPPING,
got_SIGUSR2 will be set only if WalSndCaughtUp is true. This may fail,
and then the test hangs with the inability to terminate walsender.

 > Tests:
 > * Should test something other than -1 and 0 (e.g. a positive value)

I'm not sure if it's worth adding a test containing a long timeout wait.
I can add a test-case with a small positive parameter value (for example,
200ms). However, I don't think it will be possible to verify the time period
for which the walsender was actually terminated. Still, it will be 
limited to
checking the fact of termination. What do you think?

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 →
  1. Avoid blocking indefinitely while finishing walsender shutdown

  2. Add wal_sender_shutdown_timeout GUC to limit shutdown wait for replication

  3. pg_upgrade: Add --copy option

  4. Prevent possibility of panics during shutdown checkpoint.

  5. Support clean switchover.