| From: | Zhijie Hou <houzhijie22(at)gmail(dot)com> |
|---|---|
| To: | Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> |
| Cc: | Bertrand Drouvot <bertranddrouvot(dot)pg(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-16 04:20:31 |
| Message-ID: | faf85759-1cf2-4908-90d7-983d5ac58221@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
On Sat, Nov14, 2026 at 02:18 PM Masahiko Sawada wrote:
> On Fri, Nov 13, 2026 at 7:35 PM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
> >
> > Right the reason can remain as SS_SKIP_WAL_OR_ROWS_REMOVED. Even in
> > the first cycle, the reason could be either SS_SKIP_WAL_NOT_FLUSHED
> > or SS_SKIP_WAL_OR_ROWS_REMOVED and in that case also the caller
> > update_and_persist_local_synced_slot() won't persist the slot. So, I
> > don't see a problem with retaining the previous reason when we
> > didn't perform anything in a particular sync cycle.
>
> While I agree that retaining the previous reason doesn't make us
> persist the slot, I think it's safe only because the previous reason
> is never SS_SKIP_NONE for a temporary slot at that point. That's true
> today, but it depends on several things and it would be hard to modify
> these code correctly in the future.
>
> I think the root cause is that commit 788ec96d591 replaced
> found_consistent_snapshot with the check of slotsync_skip_reason, but
> they're not equivalent: found_consistent_snapshot is false unless the
> current cycle synced the slot and found a consistent snapshot, whereas
> slotsync_skip_reason is SS_SKIP_NONE unless the current cycle detected
> a reason to skip. So an alternative idea would be to bring back
> found_consistent_snapshot part from the commit. That way, the decision
> of persisting the slot doesn't depend on the skip_reasons at all.
>
> As for the reported reason, a temporary slot is the one we have not
> confirmed to reach a consistent point yet. So I think we can simply
> report no_consistent_snapshot for a temporary slot if the current
> cycle didn't find a consistent snapshot, without relying on what
> happened in the previous cycles.
I think it would be unnecessary to reintroduce the
found_consistent_snapshot out-parameter. Because by definition,
slotsync_skip_reason is SS_SKIP_NONE (NULL in pg_replication_slots) only
when slot synchronization succeeds. Even before commit 788ec96d591
(since commit e68b6adad9), resetting slotsync_skip_reason to
SS_SKIP_NONE on a no-op cycle for a temporary slot was already a bug,
because synchronization of that temporary slot had not succeeded yet.
Once update_local_synced_slot() sets SS_SKIP_NO_CONSISTENT_SNAPSHOT
whenever "slot->data.persistency == RS_TEMPORARY && !found_consistent"
(as in your patch and v2), slotsync_skip_reason is guaranteed not to be
SS_SKIP_NONE whenever a temporary slot cannot be persisted. So I think
fixing the update_local_synced_slot to set
SS_SKIP_NO_CONSISTENT_SNAPSHOT when necessary is sufficient and avoids
maintaining two separate states for the same condition.
--
Best Regards,
Zhijie Hou
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Sho Ito | 2026-11-16 04:26:37 | [PATCH v1] Preserve implicit composite casts in ROW deparsing |
| Previous Message | Chao Li | 2026-11-16 04:04:32 | Re: Index drops during phase 1 of REINDEX CONCURRENTLY |