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 CAHGQGwFk51nAFs20-dq2SLONdeyhYcvDQb_jZiPiJt5Rinb8Ug@mail.gmail.com
Whole thread Raw
In response to Re: Exit walsender before confirming remote flush in logical replication  (Andrey Silitskiy <a.silitskiy@postgrespro.ru>)
List pgsql-hackers
On Thu, Nov 27, 2025 at 7:19 PM Andrey Silitskiy
<a.silitskiy@postgrespro.ru> wrote:
>
> On Nov 23, 2025 at 11:46 PM Fujii Masao
> <masao(dot)fujii(at)gmail(dot)com> wrote:
>  > The difference is that PGC_USERSET also allows per–replication-user
>  > overrides when needed, which gives users more flexibility without
>  > losing the ability to set a server-wide setting, I think.
>  > ...
>  > I think there are valid use cases for applying this setting to
>  > physical replication as well.
> Thanks for the comments. I agree, this parameter also seems usable
> for physical replication, if you use it with caution. In this case,
> it really becomes useful to be able to configure a parameter for
> each connection. I have added these changes to my patch.

Thanks for updating the patch!

+ /* Try to inform receiver that XLOG streaming is done */
+ SetQueryCompletion(&qc, CMDTAG_COPY, 0);
+ EndCommand(&qc, DestRemote, false);
+
+ /*
+ * Note that the output buffer may be full during immediate shutdown of
+ * walsender. If pq_flush() is called at that time, the walsender process
+ * will be stuck. Therefore, call pq_flush_if_writable() instead. Successfull
+ * receival of done message in immediate shutdown mode is not guaranteed.
+ */
+ pq_flush_if_writable();

Why do we need to send a "done" message to the receiver here?
Since delivery isn't guaranteed in immediate mode, it seems of limited value.

If it isn't necessary, do we need WalSndDoneImmediate() at all,
or could we just reuse WalSndShutdown() for immediate mode?


For the immediate mode, would it make sense to log that the walsender is
terminating in immediate mode and that WAL replication may be incomplete,
so users can more easily understand what happened?

Regards,

--
Fujii Masao



pgsql-hackers by date:

Previous
From: Bertrand Drouvot
Date:
Subject: Re: Add parallel columns for seq scan and index scan on pg_stat_all_tables and _indexes
Next
From: Kirill Reshke
Date:
Subject: Re: Buffer locking is special (hints, checksums, AIO writes)