| From: | Kacper Kuras <kacperkuras(at)hotmail(dot)com> |
|---|---|
| To: | "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com> |
| Cc: | "ua(dot)san(dot)alex(at)gmail(dot)com" <ua(dot)san(dot)alex(at)gmail(dot)com>, "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>, vignesh C <vignesh21(at)gmail(dot)com> |
| Subject: | Re: BUG #18754: Logical replication cannot restart if client sent a copyDone |
| Date: | 2026-11-22 16:33:48 |
| Message-ID: | VI0P193MB3111B1649D6D1A7CD12D3700BF462@VI0P193MB3111.EURP193.PROD.OUTLOOK.COM |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
Hi,
> To confirm, even the tablesync worker does not send the START_REPLICATION
> replication message again, right?
Right. Tablesync only relies on the walsender returning to command
mode: it starts streaming once, to catch up, and after the CopyDone
exchange it drops its slot on that connection and exits. In core,
streaming is started again on the same connection only for physical
replication: walreceiver and pg_receivewal do it when the server ends
the stream at a timeline switch, and StartReplication() resets the
flags for them.
> The fix looks enough, but the main concern is nobody in core can ensure
> re-entering the streaming mode can work well.
The test in the patch covers what is specific to a second stream: it
starts logical streaming again after a logical and after a physical
stream on the same connection, and checks that the new changes arrive
and that the server answers CopyDone. Beyond that, a second stream
runs the same code as the first one, which the existing tests cover,
so what could break it is state left over from the earlier stream.
I went through that state. Apart from these two flags, the logical
path sets it up again for each stream: the WAL reader, the decoding
context, sentPtr, the slot and the walsender state in
StartLogicalReplication(), the timeout and ping state in WalSndLoop(),
and the timeline variables on every page read in
logical_read_xlog_page(). What is not reset per stream is either
refreshed on every loop iteration, caches a flush position that can be
stale but never ahead, only matters at shutdown, or is used for the
lag columns of pg_stat_replication.
Last month f2dd2a3bd44 fixed another case of state outliving a
START_REPLICATION: the WAL reader and decoding context pointers were
left set after being freed. It clears them at the end of each
replication command and asserts that they are unset before the next
one.
Regards,
Kacper Kuras
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Srinath Reddy Sadipiralla | 2026-11-22 17:27:58 | Re: BUG #19897: Recovery fails after "LOG: consistent recovery state reached" |
| Previous Message | Raja Sai pranav | 2026-11-22 13:45:07 | Re: BUG #19928: pg_upgrade fails on v18 schema with NOT NULL ... NO INHERIT and inheritance |