Re: Assertion failure in update_local_synced_slot(), slotsync.c:364

From: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Zhijie Hou <houzhijie22(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Assertion failure in update_local_synced_slot(), slotsync.c:364
Date: 2026-11-17 08:22:46
Message-ID: avwO1mhsOTP5B2oM@bdtpg
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Mon, Nov 16, 2026 at 03:00:26PM +0530, Amit Kapila wrote:
> On Mon, Nov 16, 2026 at 1:21 PM Bertrand Drouvot
> <bertranddrouvot(dot)pg(at)gmail(dot)com> wrote:
> >
> > On Sun, Nov 15, 2026 at 10:35:57PM -0800, Masahiko Sawada wrote:
> > >
> > > I'm concerned that not only changes to this function but also changes
> > > to its callers could break these assumptions, and nothing near those
> > > places would tell us about them.
> >
> > Yeah, I agree with this concern. Looking at 788ec96d591, I think remote_slot_precedes
> > was redundant with slotsync_skip_reason, but found_consistent_snapshot was not:
> > slotsync_skip_reason reports why synchronization was skipped, while found_consistent_snapshot
> > tells the caller whether the slot is safe to persist.
> >
> > v2 is correct with the current temporary slot caller, which persists the slot
> > immediately. But relying on this call sequence seems fragile. So I'd vote for
> > restoring found_consistent_snapshot.
> >
>
> I would have equally worried if this is an exposed function but this
> is a local function used in a narrow scope. I feel the wrong usage, if
> any, we expect could be covered by Asserts. And, it could be deduced
> by slot's property whether it is safe to persist the slot or not but
> if we still want to derive it by another flag, it is better to use a
> more direct flag like 'can_persist_slot' to decide whether to persist
> the slot. Having said that, I feel we are over worried about the wrong
> usage of update_local_synced_slot().

After sleeping on this, I think that was overcautious. Given that this is a local
function and v3 makes the assumption explicit with an Assert, that looks sufficient
to me.

Regards,

--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2026-11-17 08:40:21 Re: Initial table sync copies the whole table when it is no longer published
Previous Message Jingtang Zhang 2026-11-17 08:17:37 Re: transaction_timeout is not enforced during ClientWrite