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 16:05:20
Message-ID: arP4wN5HW8h0Sr90@bdtpg
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Wed, Sep 23, 2026 at 04:07:02PM +0530, shveta malik wrote:
> Can we create the helper function for this logic as it is not core to
> the sync-function. Please use the attached patch if you agree, and
> feel free to change comments as you see apt.

I was initially a bit skeptical about adding a helper with only one caller, as it
seemed to just move the PG_TRY() block elsewhere without reducing duplication.

On second thought, I agree it makes sense here, as it keeps the lock acquisition
and required ERROR cleanup ordering together. There are also similar "one caller"
helpers wrapping PG_TRY() blocks, such as start_table_sync() and start_sequence_sync().

+static void
+persist_slot_invalidation(ReplicationSlot *slot, ReplicationSlotInvalidationCause cause)
+{

I changed it slightly to derive slot from MyReplicationSlot, ensuring that the I/O
lock belongs to the same slot that ReplicationSlotPersistInvalidation() and
and ReplicationSlotRelease() are using. This is also consistent with other operations
on the currently acquired slot.

Please find v5 attached.

Regards,

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

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Nurlan Tulemisov 2026-09-23 16:15:44 Re: Import Statistics in postgres_fdw before resorting to sampling.
Previous Message Florents Tselai 2026-09-23 15:20:05 Re: add list of major features to the v19 release notes