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

From: Zhijie Hou <houzhijie22(at)gmail(dot)com>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Ajin Cherian <itsajin(at)gmail(dot)com>
Cc: 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-01 09:06:38
Message-ID: 1b885669-20a1-4d62-91de-885427e1d029@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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".

--
Best Regards,
Zhijie Hou

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message shveta malik 2026-12-01 09:19:38 ALTER DEFAULT PRIVILEGES IN SCHEMA pg_conflict silently has no effect
Previous Message Florin Irion 2026-12-01 08:41:50 Re: pg_plan_advice: add NO_ scan and join method tags