Re: Persist slot invalidations before publishing them

From: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: shveta malik <shveta(dot)malik(at)gmail(dot)com>
Cc: JoongHyuk Shin <sjh910805(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Rui Zhao <zhaorui126(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Persist slot invalidations before publishing them
Date: 2026-09-23 08:38:00
Message-ID: arOP6DEhgKcsNS5b@bdtpg
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Wed, Sep 23, 2026 at 12:00:39PM +0530, shveta malik wrote:
> On Wed, Sep 23, 2026 at 11:37 AM Bertrand Drouvot
> <bertranddrouvot(dot)pg(at)gmail(dot)com> wrote:
> >
> > Another possibility would be to make ReplicationSlotPersistInvalidation() always
> > leave the caller acquired I/O lock held. Slotsync could then release that specific
> > lock in a PG_CATCH() block, something like:
>
> Yes, I agree. I find this approach much better for 2 reasons:
>
> 1) The caller has better control over the lock, which makes sense
> since it is the one acquiring it.
> 2) It makes the code much more understandable. Earlier, it took me a
> while to figure out exactly where the io_in_progress_lock was getting
> released, especially looking at the slotsync patch where it was
> acquired right before calling ReplicationSlotPersistInvalidation().
>
> > "
> > PG_CATCH();
> > {
> > HOLD_INTERRUPTS();
> > LWLockRelease(&slot->io_in_progress_lock);
> > PG_RE_THROW();
> > }
> > PG_END_TRY();
> >
> > LWLockRelease(&slot->io_in_progress_lock);
> > "
> >
> > This would avoid both LWLockReleaseAll() and using LWLockHeldByMe() for normal
> > control flow. Does that sound preferable?
>
> Yes.

Thanks! Done that way in v4 attached.

Regards,

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

Attachment Content-Type Size
v4-0001-Persist-slot-invalidations-before-publishing-them.patch text/x-diff 29.3 KB
v4-0002-Persist-synchronized-slot-invalidations-before-pu.patch text/x-diff 7.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2026-09-23 08:48:25 Re: Revert RI fast-path batching from REL_19_STABLE
Previous Message Álvaro Herrera 2026-09-23 08:36:10 Re: [PATCH] Misleading error message for REPACK USING INDEX on shared catalogs