Re: Persist slot invalidations before publishing them

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Persist slot invalidations before publishing them
Date: 2026-08-28 10:29:32
Message-ID: CAA4eK1LH_yjAwcn87gxdawJn+VsAt5HSjXdfAA7gBB-Gb9BGaA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Aug 26, 2026 at 7:19 PM Bertrand Drouvot
<bertranddrouvot(dot)pg(at)gmail(dot)com> wrote:
>
> while reviewing [1], I hit an issue due to the fact that an inactive replication
> slot is marked invalid in shared memory before its new state is persisted.
>
> If ReplicationSlotSave() errors before replacing the state file, the slot is
> invalid in shared memory but still valid on disk. That sounds problematic as the
> resource horizon computations could stop accounting for the slot, remove required
> WAL or rows, and then an immediate restart would restore the old valid slot image.
>
> The same issue exists in synchronize_one_slot(): it copies the invalidation from
> the remote slot into the local synchronized slot before saving it. In that case,
> a save error also prevents a direct retry because the next synchronization sees
> the local slot as already invalid and skips it.
>

Won't the drop_local_obsolete_slots() drop the locally invalidated
slot before trying to synchronize the remote_slot in the next slot?

--
With Regards,
Amit Kapila.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message 达劳里亚斯 2026-08-28 10:43:07 Re: pg_upgrade --copy-file-range fails with EINVAL on Linux 4.19
Previous Message Yuhang Qiu 2026-08-28 10:04:57 Re: [PATCH] Use streaming read I/O in sample scans