Re: Avoid resetting subscription two_phase state to pending when already enabled

From: Zhijie Hou <houzhijie22(at)gmail(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>, shveta malik <shveta(dot)malik(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, shveta malik <shvetamalik(at)gmail(dot)com>
Subject: Re: Avoid resetting subscription two_phase state to pending when already enabled
Date: 2026-11-04 12:50:11
Message-ID: CAFvd2n8vxiu4CB78w-Agx+MxUzLAjdGLKZWOpT3uunLQUifMRQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Wed, Nov 4, 2026 at 6:01 PM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
>
> On Thu, Oct 29, 2026 at 8:44 PM Zhijie Hou <houzhijie22(at)gmail(dot)com> wrote:
> >
> > On Thu, Oct 29, 2026 at 06:41 PM Bertrand Drouvot wrote:
> > > It might be worth fixing, as preserving 'e' only when slot_name is unchanged
> > > should be simple enough.
> >
> > I don't think handling that here would be simple. Resetting ENABLED to
> > PENDING when slot_name is changed would re-introduce the same bugs that
> > this patch aims to fix: prepared transactions from the previous slot may
> > still exist on the subscriber, and if the replacement slot already has
> > two_phase enabled on the publisher, prepared transactions could again be
> > streamed concurrently with table synchronization. Avoiding that would
> > require checking prepared transactions and the remote slot's status
> > during the change, which would complicate the fix.
> >
>
> I agree that we don't need to preserve the old behavior as it will
> open up other bugs and we already document that such slot's properties
> should match subscription's options. But I feel we should add that
> change in behavior for new slot's in the commit message. Other than
> that the latest patch in this thread looks good to me.

I added a section describing this behavior change, please see the
attached V3 patch.

I confirmed the patch applies cleanly to all affected branches (PG 18
through HEAD),
and the tests pass on all of them.

--
Best Regards,
Zhijie Hou

Attachment Content-Type Size
v3-0001-Avoid-resetting-subscription-two_phase-state-to-p.patch application/octet-stream 5.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim Jones 2026-11-04 12:54:58 Re: possible bug - xmlconcat is badly marked as immutable
Previous Message jian he 2026-11-04 12:19:35 Re: [PATCH v1] Fix for bug #19773 : pg_dump differing generation expressions of inherited columns