Re: Detect mismatched subscription and replication slot properties

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Bertrand Drouvot <bertranddrouvot(dot)pg(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-25 11:11:02
Message-ID: CAA4eK1L+hgO9EpwwC490EQdNVMJbdw7Gj5U7VOO7GQGRkn-E8A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Nov 23, 2026 at 3:30 PM Bertrand Drouvot
<bertranddrouvot(dot)pg(at)gmail(dot)com> wrote:
>
> On Sat, Nov 21, 2026 at 06:35:47PM +0530, Amit Kapila wrote:
> > On Thu, Nov 19, 2026 at 1:35 PM Bertrand Drouvot
> > <bertranddrouvot(dot)pg(at)gmail(dot)com> wrote:
> > >
> > > On Thu, Nov 19, 2026 at 01:09:42PM +0530, Amit Kapila wrote:
> > >
> > > 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?
> > >
> >
> > I feel so. I think it would be good to have such checks with no or
> > minimal cost in terms of additional infrastructure as we expect users
> > to set up replication appropriately, otherwise it can fail in many
> > ways.
>
> Fair enough. For two_phase, Hou-san's approach seems to fit that (did not look in
> details yet).
>
> > > 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.
> > >
> >
> > Possible, but again let's try to find some way if possible to catch
> > differences in publisher and subscriber without additional options or
> > a totally new infrastructure, otherwise, we can rely on the
> > documentation as we do now. OTOH, if we see user complaints in this or
> > related differences between pub-sub configuration misbehaving then we
> > can try to build something better to catch the differences.
>
> For failover, querying pg_replication_slots just before START_REPLICATION and
> issuing a WARNING on mismatch looks like the right approach then. The race window
> should be small, but since the check is not atomic, a WARNING seems more appropriate
> than an ERROR.
>
> The documentation would still require the values to match.
>
> What do you think?
>

Sounds reasonable.

--
With Regards,
Amit Kapila.

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Tomas Vondra 2026-11-25 11:11:00 BRIN may be missing HOT-updated rows on old snapshots