| From: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> |
|---|---|
| To: | Zhijie Hou <houzhijie22(at)gmail(dot)com> |
| Cc: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Detect mismatched subscription and replication slot properties |
| Date: | 2026-11-19 07:39:42 |
| Message-ID: | CAA4eK1KKyP_r1LGrZOEhzBu8cY6O71aGHn_p_UjbLYxHam+OXA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Thu, Nov 19, 2026 at 12:02 PM Zhijie Hou <houzhijie22(at)gmail(dot)com> wrote:
>
> On Wed, Nov18, 2026 at 10:15 PM Bertrand Drouvot wrote:
> >
> > On Mon, Nov 16, 2026 at 03:46:25PM +0530, Amit Kapila wrote:
> > > On Tue, Nov 10, 2026 at 7:44 PM Bertrand Drouvot
> > > > For failover, the value should match exactly.
> > > >
> > > > For two_phase, the expected value depends on subtwophasestate:
> > > >
> > > > • DISABLED: the slot must have two_phase = false.
> > > > • PENDING, before the tables are ready: it must remain false.
> > > > • PENDING, once the tables are ready: either value can be accepted before enabling
> > > > it and recording the state as ENABLED. This also makes the
> > > > transition safe if the worker previously exited between those two
> > > > operations.
> > > > • ENABLED: the slot must have two_phase = true.
> > > >
> > >
> > > Instead of PENDING state checks, how about checking mismatch in
> > > begin_prepared kind of functions whether the subscription has
> > > reached ENABLED state? I am asking this because if the slot is
> > > initially created with two_phase = true and the subscription is in
> > > pending state then the apply worker will start receiving prepared
> > > transactions and will lead to problems described under "TWO_PHASE
> > > TRANSACTIONS" in worker.c.
> >
> > Thanks for looking at it!
> >
> > I think that could be too late. With parallel streaming, a parallel
> > apply worker may already have executed the transaction's changes.
>
>
> IIUC, it wouldn't be too late. Even if the changes are already being
> executed, the transaction won't be prepared if we catch the mismatch in
> apply_handle_prepare (and related functions).
>
Right, I also thought so. Also, I don't like adding new options for
detecting these ERROR cases, the main idea is that such differences
should not lead to inconsistencies. BTW, I don't know what to do for a
failover property if we go with this idea? Do we need to perform a SQL
query to get the required slot properties and then compare it with
current subscription properties?
--
With Regards,
Amit Kapila.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Chao Li | 2026-11-19 07:42:09 | Re: Fix resource leaks in pg_receivewal on LZ4 close failures |
| Previous Message | Chao Li | 2026-11-19 07:39:21 | Re: Fix ISSN output truncation when the issue code is nonzero |