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

From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: Zhijie Hou <houzhijie22(at)gmail(dot)com>
Cc: Ajin Cherian <itsajin(at)gmail(dot)com>, Bertrand Drouvot <bertranddrouvot(dot)pg(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-12-03 22:28:15
Message-ID: CAD21AoA21QX+=3bVPDZK4A6cDTz6yVJJ64+Vqy8fUJPQ=24LCA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Dec 1, 2026 at 1:06 AM Zhijie Hou <houzhijie22(at)gmail(dot)com> wrote:
>
> Hi,
>
> On Sat, Nov21, 2026 at 02:35 AM Masahiko Sawada wrote:
> > Good find. Since we already treat msg.lsn as the position the message
> > is applied at when reporting the flush position, it makes sense to
> > advance the origin to it as well, as we do for commits.
> >
> > Given that we’ve agreed on the 0001 patch, I’m going to push it early
> > next week, barring any objections. I’d like to hold off on the 0002
> > patch to give it more review time.
>
> Thanks for pushing 0001!
>
> I reviewed 0002 and have few comments:
>
> 1.
>
> + if (!MySubscription->messages || am_tablesync_worker())
> + ereport(ERROR,
> + (errcode(ERRCODE_PROTOCOL_VIOLATION),
> + errmsg_internal("MESSAGE message received but messages are not
> enabled for this worker")));
>
> I hit the above internal error in a parallel apply worker when disabling
> the "messages" option. I think the reason is that the parallel apply
> worker could re-read the subscription info earlier than the leader
> worker; since parallel apply workers don't exit on option changes (see
> apply_worker_exit()), it updated MySubscription->messages to false and
> then processed an in-flight MESSAGE sent by the leader, triggering this
> error. Maybe we can skip the !MySubscription->messages check in parallel
> apply workers to avoid this.
>
> 2.
>
> The ordering of the "submessages" column in catalogs.sgml (and
> system_views.sql) differs from pg_subscription.h, where "submessages" is
> placed before "subconflictlogdest".

Thank you for reviewing the patch! I agree with both points.

I've updated the patch accordingly and attached the new version patch.

Regards,

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

Attachment Content-Type Size
v11-0001-Add-a-hook-for-handling-logical-messages-on-subs.patch text/x-patch 124.1 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Peter Smith 2026-12-03 22:03:12 Re: Include schema-qualified names in publication error messages (generalised to all of LR).