Re: Detect mismatched subscription and replication slot properties

From: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: Zhijie Hou <houzhijie22(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 08:05:41
Message-ID: av6t1WBXhX1WHT+o@bdtpg
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Thu, Nov 19, 2026 at 01:09:42PM +0530, Amit Kapila wrote:
> On Thu, Nov 19, 2026 at 12:02 PM Zhijie Hou <houzhijie22(at)gmail(dot)com> wrote:
> > >
> > > 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.

I agree that the transaction itself will not be prepared and its transactional
changes will be rolled back. My concern is that, with parallel streaming,
subscriber nontransactional effects may already have occurred before
STREAM PREPARE (for example, subscriber having a default column calling nextval()).

This can also happen with other apply errors, so it is not new. However, this
particular error is predictable before decoding starts, and checking there
avoids entering that path unnecessarily.

Maybe I'm being overly concerned about this though?

> Also, I don't like adding new options for
> detecting these ERROR cases,

Yeah, I see the concern. The reason for passing the expected values to pgoutput
is to let the publisher validate the actual slot after acquiring it and before
decoding starts.

> 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?

I considered that too, as mentioned up-thread. My concern is that the slot could
be changed or recreated between the query and its acquisition by START_REPLICATION.

Regards,

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Nazir Bilal Yavuz 2026-11-19 07:57:09 Re: CI slowdown due to PG_TEST_INITDB_EXTRA_OPTS