| From: | shveta malik <shveta(dot)malik(at)gmail(dot)com> |
|---|---|
| To: | Zhijie Hou <houzhijie22(at)gmail(dot)com> |
| Cc: | wangyang25(at)otcaix(dot)iscas(dot)ac(dot)cn, pgsql-bugs(at)lists(dot)postgresql(dot)org, shveta malik <shvetamalik(at)gmail(dot)com> |
| Subject: | Re: Inactive physical replication slot can bypass synchronized_standby_slots confirmation |
| Date: | 2026-11-25 04:38:57 |
| Message-ID: | CAJpy0uDeR=Q7g_WQ_uZc8Gdnk9aGCOdruGv84Y-r6v_D4PykpA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
On Wed, Nov 25, 2026 at 7:58 AM Zhijie Hou <houzhijie22(at)gmail(dot)com> wrote:
>
> Hi,
>
> On Mon, Nov23, 2026 at 05:41 PM wangyang25(at)otcaix(dot)iscas(dot)ac(dot)cn wrote:
> >
> > Summary
> >
> > An inactive physical replication slot can satisfy synchronized_standby_slots using its initial restart_lsn, even when no standby has connected or confirmed receipt of WAL. A failover logical slot can then return and consume changes before the physical standby has confirmed them.
> >
>
> This is as expected. If a standby has already confirmed WAL flush up to
> restart_lsn and then disconnects, it already has those changes on disk,
> so logical decoding should not wait for WAL at or before restart_lsn.
> Requiring the slot to be active here would also break clean primary
> shutdown if the physical walsender exits before the logical walsender
> checks the slot.
+1, I agree this is expected behaviour.
The CHECKPOINT in the reproducer is what makes it work. It moves the
redo pointer up to target, so reserving WAL sets restart_lsn exactly
at target. I verified this on HEAD. Without the CHECKPOINT,
restart_lsn stays behind target, and without reserving WAL it is NULL.
In both cases pg_logical_slot_get_changes() waits and repeatedly logs
that the slot does not have an active_pid, and the logical slot's
confirmed_flush_lsn doesn't advance.
Also, a standby that has never connected has no synced failover slots,
so even in this case there is nothing on it for logical replication to
fail over to. So I don't see a practical data-loss (or inconsistency)
scenario either.
> In your test, pg_create_physical_replication_slot('report_phys', true)
> sets restart_lsn to the latest checkpoint's redo LSN to reserve WAL for
> a subsequent base backup. Any standby built from a base backup taken
> afterward will already contain the earlier INSERT, while any WAL
> generated after restart_lsn will still wait for standby confirmation. So
> I don't think this is a bug.
>
> --
> Best Regards,
> Zhijie Hou
>
>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2026-11-25 05:07:04 | Re: BUG #18754: Logical replication cannot restart if client sent a copyDone |
| Previous Message | Hayato Kuroda (Fujitsu) | 2026-11-25 04:38:42 | RE: BUG #18754: Logical replication cannot restart if client sent a copyDone |