pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
To: Zhijie Hou <houzhijie22@gmail.com>
Cc: shveta malik <shveta.malik@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org, amit.kapila16@gmail.com, shveta malik <shvetamalik@gmail.com>
Subject: Re: Avoid resetting subscription two_phase state to pending when already enabled
Date: Thu, 29 Oct 2026 09:11:27 +0000
Message-ID: <auMNvwNHAidX1t02@bdtpg> (raw)
In-Reply-To: <3ba34b9c-455e-487c-9815-8a7f31297065@gmail.com>
References: <8e85abdf-738b-4578-ac42-4dc8eaa061dd@gmail.com>
	<CAJpy0uBnm2TkxZ3DQcjUqrXUzz07ojkeFamz6Oh=rv8JZwLr9w@mail.gmail.com>
	<3ba34b9c-455e-487c-9815-8a7f31297065@gmail.com>

Hi,

On Thu, Oct 29, 2026 at 03:04:12PM +0800, Zhijie Hou wrote:
> Agreed. I adjusted the test order to make it clear.
> 
> Here is the V2 patch.

Thanks for the patch!

+         /*
+          * Change system catalog accordingly, but do not reset the
+          * state to PENDING if two_phase is already enabled.
+          */
+          if (!(opts.twophase &&
+                sub->twophasestate == LOGICALREP_TWOPHASE_STATE_ENABLED))

The new condition also preserves 'e' when slot_name changes. In that case, a
replacement slot with two_phase=false remains false because the worker does not
go through the PENDING state.

I reproduced this with:

ALTER SUBSCRIPTION sub SET (slot_name = 'replacement', two_phase = true);

Should we preserve 'e' only when the slot name is unchanged?

Regards,

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






view thread (18+ messages)  latest in thread

Message-ID: <auMNvwNHAidX1t02@bdtpg>
Permalink:  ../auMNvwNHAidX1t02@bdtpg/
Also on:    postgresql.org/message-id/auMNvwNHAidX1t02@bdtpg

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: bertranddrouvot.pg@gmail.com, houzhijie22@gmail.com, shveta.malik@gmail.com, shvetamalik@gmail.com
  Subject: Re: Avoid resetting subscription two_phase state to pending when already enabled
  In-Reply-To: <auMNvwNHAidX1t02@bdtpg>
  References: <8e85abdf-738b-4578-ac42-4dc8eaa061dd@gmail.com> <CAJpy0uBnm2TkxZ3DQcjUqrXUzz07ojkeFamz6Oh=rv8JZwLr9w@mail.gmail.com> <3ba34b9c-455e-487c-9815-8a7f31297065@gmail.com> <auMNvwNHAidX1t02@bdtpg>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox