| From: | vignesh C <vignesh21(at)gmail(dot)com> |
|---|---|
| To: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com> |
| Cc: | Zhijie Hou <houzhijie22(at)gmail(dot)com>, 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 10:22:46 |
| Message-ID: | CALDaNm1M4TWztQJAkWGF8pefz8KWELf=uMBWHMQyjKEjvnpCpw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Thu, 29 Oct 2026 at 14:41, Bertrand Drouvot
<bertranddrouvot(dot)pg(at)gmail(dot)com> wrote:
>
> 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?
There is the following documentation mentioning that slots must be
created with the same parameters of the subscription at [1].
When altering the slot_name, the failover and two_phase property
values of the named slot may differ from the counterpart failover and
two_phase parameters specified in the subscription. When creating the
slot, ensure the slot properties failover and two_phase match their
counterpart parameters of the subscription. Otherwise, the slot on the
publisher may behave differently from what these subscription options
say: for example, the slot on the publisher could either be synced to
the standbys even when the subscription's failover option is disabled
or could be disabled for sync even when the subscription's failover
option is enabled.
A similar thing can happen with SET (slot_name = 'other_slot') i.e,
without specifying two_phase option.
I'm not sure if this should be handled here as it is documented already.
[1] - https://www.postgresql.org/docs/devel/sql-altersubscription.html
Regards,
Vignesh
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Bertrand Drouvot | 2026-10-29 10:41:49 | Re: Avoid resetting subscription two_phase state to pending when already enabled |
| Previous Message | David Geier | 2026-10-29 09:46:09 | Re: Hash a ScalarArrayOpExpr whose array is fixed for one execution |