Re: Issue with logical replication slot during switchover

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: Fabrice Chapuis <fabrice636861(at)gmail(dot)com>, shveta malik <shveta(dot)malik(at)gmail(dot)com>, Alexander Kukushkin <cyberdemn(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com>
Subject: Re: Issue with logical replication slot during switchover
Date: 2025-11-24 09:04:41
Message-ID: CAA4eK1+gvQb1iD4xqb+qmxC_P5Gk6G5noSeKbDanoaaBnjfCxQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Nov 21, 2025 at 2:05 AM Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
>
> On Thu, Nov 20, 2025 at 6:26 AM Fabrice Chapuis <fabrice636861(at)gmail(dot)com> wrote:
> >
> > The problem I see is being able to distinguish between 2 situations:
> > 1) A failover slot has been created on a standby (failover=true and synced=false) in a context of cascading standby. In this case the slot must not be deleted.
> > 2) A former primary has a slot (failover=true and synced=false) that must be resynchronized and that can be overwritten.
>
> Right.
>
> > Why not to use a slot's metadata (allow_overwrite) to treat these two situations separately.
>
> I'm not sure that the allow_overwrite idea is the best approach. For
> example, suppose that in a cascading replication setup (node-1 ->
> node2 -> node3) we create a failover slot on node2 (failover=true,
> synced=false, and allow_overwrite=false), the slot is synchronized to
> the node3 (failover=true, synced=true, allow_overwrite=false). If we
> do a switchover between node2 and node3, node3 joins the primary,
> node1, and node2 now joins node3 as a cascaded standby (i.e.,
> replication setup is now node1 -> node3 -> node2). I guess that in
> this case the slot on node2 wants to be overwritten by the one on the
> node3, but it's not allowed because the slot on node2 has
> allow_overwrite=false.
>

IIRC, we discussed the pg_alter_replication_slot() API which will
allow us to alter this new property (allow_overwrite or whatever we
name it) of slots and some existing properties like two_phase, etc.

--
With Regards,
Amit Kapila.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Banck 2025-11-24 09:18:23 Re: [PATCH] Expose checkpoint timestamp and duration in pg_stat_checkpointer
Previous Message Mircea Cadariu 2025-11-24 09:03:41 Re: pg_recvlogical: Prevent flushed data from being re-sent after restarting replication