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

From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(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-08-04 00:41:52
Message-ID: CAD21AoBqVO_fwLkvxwzibohpMG-7n+7MqgkD9qRMGTVN6e8x7g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jul 9, 2026 at 5:14 AM Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
>
> On Wed, Jun 24, 2026 at 3:02 AM Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
> > Right. I'm implementing a basic DDL replication solution using this
> > hook as a sample implementation. Other than that, this feature can be
> > used to add additional information for the replicated transaction that
> > is not replicated via logical replication protocol, such as the
> > executed user or context-specific information, which can then be
> > dispatched to a CDC system connected to the subscriber.
>
> +1 for the proposed hook, although I haven't read the patch yet.
>
> I know of a system that uses logical decoding messages to propagate data
> to external systems. In that system, the application writes the data to
> be propagated as logical decoding messages, and a CDC pipeline consumes
> them via logical decoding and sends them to other systems, for example
> through Kafka.
>
> In that system, when the remote site is maintained by physical replication,
> the same logical decoding messages can be decoded on the standby
> at the remote site to deliver them to external systems there. However,
> if the remote site uses logical replication instead, those messages are
> currently neither delivered to nor processed on the subscriber at
> the remote site. As a result, the CDC pipeline at the remote site cannot
> consume the data they carry.
>
> The proposed hook might be useful for this use case. An extension could
> process the incoming logical decoding messages on the subscriber and
> forward them to the local CDC pipeline, or store or re-emit them in a form
> that local consumers can process.

Thank you for sharing the concrete use case. This is one of the use
cases I initially imagined.

I've rebased and updated the patch. Please review it.

Regards,

--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com

Attachment Content-Type Size
v2-0001-Add-a-hook-for-handling-logical-messages-on-subsc.patch text/x-patch 108.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Davis 2026-08-04 01:00:57 Re: CREATE SUBSCRIPTION ... SERVER vs. pg_dump, etc.
Previous Message Neil Chen 2026-08-04 00:38:46 Re: [PATCH] Fix vacuum_delay_point happening inside lock