Re: Fix race between copying and dropping a replication slot

From: Zhijie Hou <houzhijie22(at)gmail(dot)com>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Fix race between copying and dropping a replication slot
Date: 2026-12-02 02:20:19
Message-ID: 7ebfebcc-ff16-461b-8282-3bdb00d1dfe9@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Wed, Dec 2, 2026 at 04:00 AM Masahiko Sawada wrote:
> On Tue, Dec 1, 2026 at 4:47 AM Zhijie Hou <houzhijie22(at)gmail(dot)com> wrote:
> >
> >
> > Thanks for the comments! Both comments have been addressed in v2 patch.
>
> Thank you for updating the patch! The patch looks good to me. Could
> you prepare the patch for back branches? The new isolation test uses
> the injection point 'replication-slot-create-begin', which exists only
> in v19 and later. For v17 and v18, I think we can have the same test
> if we add the injection point there too. What do you think?

Yes, I agree. Added in the V3.

>
> Also, regarding the following test steps, is there any reason we need
> these steps?
>
> +step s2_checkpoint
> +{
> + CHECKPOINT;
> +}
> +step s2_switch_wal
> +{
> + SELECT FROM pg_switch_wal();
> +}

I originally added to trigger WAL removal for the cassert failure, but I
think it is not needed since the copy already unexpectedly succeeds
without the fix. Removed in v3 for simplification.

Here are the patches for all branches.

--
Best Regards,
Zhijie Hou

Attachment Content-Type Size
v3-0001-Fix-race-between-copying-and-dropping-a-replicati-HEAD.patch text/plain 11.1 KB
v3-0001-Fix-race-between-copying-and-dropping-a-replicati-PG15-PG16.patch text/plain 6.7 KB
v3-0001-Fix-race-between-copying-and-dropping-a-replicati-PG17.patch text/plain 12.8 KB
v3-0001-Fix-race-between-copying-and-dropping-a-replicati-PG18.patch text/plain 12.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2026-12-02 02:27:40 Re: Preserve conflict log table during upgrade
Previous Message Chao Li 2026-12-02 02:12:58 Re: [PATCH] Reuse slot helpers in pg_get_replication_slots and slot copy