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

From: Ajin Cherian <itsajin(at)gmail(dot)com>
To: shveta malik <shveta(dot)malik(at)gmail(dot)com>
Cc: Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Clear logical slot's 'synced' flag on promotion of standby
Date: 2025-10-03 09:17:55
Message-ID: CAFPTHDbQYVkfwwS_3vuzq0qCfJQ=9kzSdxjMkfqcYSq1TurijA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Sep 29, 2025 at 4:11 PM shveta malik <shveta(dot)malik(at)gmail(dot)com> wrote:
>
> On Fri, Sep 26, 2025 at 3:26 PM Ajin Cherian <itsajin(at)gmail(dot)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

Attachment Content-Type Size
v5-0001-Reset-synced-slots-when-a-standby-is-promoted.patch application/octet-stream 8.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Aya Iwata (Fujitsu) 2025-10-03 09:27:23 [PROPOSAL] Termination of Background Workers for ALTER/DROP DATABASE
Previous Message Mingli Zhang 2025-10-03 09:16:50 Re: Fix incorrect function reference BufFileOpenShared in comment.