Re: Add a hook for handling logical decoding messages on subscribers.

From: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: Zhijie Hou <houzhijie22(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add a hook for handling logical decoding messages on subscribers.
Date: 2026-11-18 06:43:47
Message-ID: av1JIyFMSMRXzzt0@bdtpg
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Tue, Nov 17, 2026 at 02:14:15PM -0800, Masahiko Sawada wrote:
> On Tue, Nov 17, 2026 at 12:14 AM Bertrand Drouvot
> <bertranddrouvot(dot)pg(at)gmail(dot)com> wrote:
> >
> > Hi,
> >
> > On Mon, Nov 16, 2026 at 11:05:00AM -0800, Masahiko Sawada wrote:
> > >
> > > I've attached the updated patches.
> >
> > Thanks!
> >
> > I did not look in details but I have a question. I'm wondering what would happen
> > with an unpatched publisher when both messages and streaming are enabled. Suppose
> > a message is emitted in a subtransaction that is later aborted. The publisher
> > sends the top level XID with the message, whereas STREAM ABORT refers to the
> > subtransaction XID. IIUC, the patched subscriber would therefore not discard that
> > message.
> >
> > Should 0002 handle this case somehow?
>
> Good point. In that case, the subscriber would apply the message when
> the top-level transaction commits, even though the subtransaction that
> emitted it was rolled back.

Yeah, thanks for confirming.

> Given that the 0001 patch is not backpatched, I think the subscriber
> should request the messages option only from v20 or later publishers,
> like it doesn't send the origin option to publishers older than v16.
> The patch already checks the publisher version there, so we just need
> to raise it from v14 to v20. What do you think?

One difference with origin is that older publishers do not support that option
at all, whereas v14 through v19 publishers support messages and the issue occurs
only when streaming is enabled.

I wonder if it would make sense to request messages from those publishers when
streaming is disabled, and require v20 or later when streaming is enabled?

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
Next Message Hayato Kuroda (Fujitsu) 2026-11-18 06:51:48 RE: Allow pg_read_all_stats to read replication origin status
Previous Message Chao Li 2026-11-18 06:31:33 Re: [PATCH] Reject duplicate SQL/JSON PASSING argument names