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

From: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: Zhijie Hou <houzhijie22(at)gmail(dot)com>
Cc: shveta malik <shveta(dot)malik(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, amit(dot)kapila16(at)gmail(dot)com, shveta malik <shvetamalik(at)gmail(dot)com>
Subject: Re: Avoid resetting subscription two_phase state to pending when already enabled
Date: 2026-10-29 09:11:27
Message-ID: auMNvwNHAidX1t02@bdtpg
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2026-10-29 09:31:07 Re: WAL record CRC calculated incorrectly because of underlying buffer modification
Previous Message shveta malik 2026-10-29 08:51:20 Re: Proposal: Conflict log history table for Logical Replication