Re: Exit walsender before confirming remote flush in logical replication - Mailing list pgsql-hackers

From Fujii Masao
Subject Re: Exit walsender before confirming remote flush in logical replication
Date
Msg-id CAHGQGwGW9w=KkHK-1t_30+27WB4Hgwy7cgQpjPM9BPdqTTD6+g@mail.gmail.com
Whole thread
In response to Re: Exit walsender before confirming remote flush in logical replication  (Chao Li <li.evan.chao@gmail.com>)
Responses Re: Exit walsender before confirming remote flush in logical replication
List pgsql-hackers
On Fri, Apr 24, 2026 at 11:05 AM Chao Li <li.evan.chao@gmail.com> wrote:
> ProcessPendingWrites() calls ProcessRepliesIfAny() in the first place, so if it is possible that, a new COPY message
isappended after the already-queued CommandComplete? Which seems to violate the protocol, but I am not sure if that
wouldlead to any trouble. 
>
> So, maybe we need a new helper, say ProcessPendingWritesForShutdown(), that loops while pq_is_send_pending(), call
WalSndCheckShutdownTimeout()and only wait for WL_SOCKET_WRITEABLE, then pq_flush_if_writable(), on flush failure, maybe
WalSndShutdown().

Thanks for the review! You're right.

I added such loop directly in WalSndDone() instead of introducing a new helper
function, since only WalSndDone() needs it and the extra loop does not make
WalSndDone() significantly more complicated.

I've attached an updated patch.

Regards,

--
Fujii Masao

Attachment

pgsql-hackers by date:

Previous
From: shveta malik
Date:
Subject: Re: Proposal: Conflict log history table for Logical Replication
Next
From: Jim Jones
Date:
Subject: Re: PoC - psql - emphases line with table name in verbose output