Re: Clear logical slot's 'synced' flag on promotion of standby

Ajin Cherian <itsajin@gmail.com>

From: Ajin Cherian <itsajin@gmail.com>
To: shveta malik <shveta.malik@gmail.com>
Cc: Ashutosh Sharma <ashu.coek88@gmail.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-10-03T09:17:55Z
Lists: pgsql-hackers

Attachments

On Mon, Sep 29, 2025 at 4:11 PM shveta malik <shveta.malik@gmail.com> wrote:
>
> On Fri, Sep 26, 2025 at 3:26 PM Ajin Cherian <itsajin@gmail.com> wrote:
> >
> >
> > Attaching v4 which addresses all the above comments.
> >
>
> Few trivial comments:
>
> 1)
>  # Confirm the synced slot 'lsub1_slot' is retained on the new primary
>  is( $standby1->safe_psql(
>   'postgres',
> - q{SELECT count(*) = 2 FROM pg_replication_slots WHERE slot_name IN
> ('lsub1_slot', 'snap_test_slot') AND synced AND NOT temporary;}
> + q{SELECT count(*) = 2 FROM pg_replication_slots WHERE slot_name IN
> ('lsub1_slot', 'snap_test_slot') AND NOT synced AND NOT temporary;}
> +
>   ),
>   't',
>   'synced slot retained on the new primary');
>
> a)
> It is not fault of this patch, but I see comment and query not
> matching. We shall have  both the names 'lsub1_slot', 'snap_test_slot'
> in comment.
>

Fixed.

> b) Also it will be good to mention the expectation from synced flag in
> the comment. How about:
>
> Confirm the synced slots 'lsub1_slot' and 'snap_test_slot' are
> retained on the new primary and 'synced' flag is cleared on promotion.
>

Added.

> 2)
> As Ashutosh suggested, even in RestoreSlotFromDisk(), we can have
> DEBUG1 msg: "synced flag reset for replication slot \"%s\""
>

Added.

Attaching patch v5 addressing the above changes.

regards,
Ajin Cherian
Fujitsu Australia