| From: | Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> |
|---|---|
| To: | Zhijie Hou <houzhijie22(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-11-16 19:05:00 |
| Message-ID: | CAD21AoCbrcp=E5M4uMxfHLXsJsKfDscBoy-Bfhvqt6YuMhOEgw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Sun, Nov 15, 2026 at 9:13 AM Zhijie Hou <houzhijie22(at)gmail(dot)com> wrote:
>
> Hi,
>
> On Sat, Nov14, 2026 at 07:35 AM Masahiko Sawada wrote:
> >
> > Agreed. It's better for callbacks to get both top-level and
> > subtransaction's ids.
> >
> > I've updated the patches (the 0002 patch unchanged).
>
> > - ctx->write_xid = txn != NULL ? txn->xid : InvalidTransactionId;
> > + ctx->write_xid = xid;
>
> I think it would be better to keep the original code for consistency, as
> all the other callbacks set ctx->write_xid to txn->xid (the top-level
> transaction's XID). IIUC, this was changed to make the test pass since
> test_decoding does not otherwise output the subxid, but we could instead
> use pgoutput to test that and keep passing the top-level XID in
> ctx->write_xid. Please see the attached top-up patch for this change.
Agreed. I've applied your patch.
> BTW, since we are changing the callback signature anyway, another wild
> idea would be to pass ReorderBufferChange directly instead so that it is
> fully consistent with the other change callbacks. That said, it would
> require more changes in third-party output plugins, so I don't insist on
> it if you disagree — just sharing for reference.
It seems overkill to me. For non-transactional messages, we don't
create a ReorderBufferChange for them, so we would have to allocate
one just for the callback and copy the prefix and the message into it.
We would still need a separate transactional argument, so I guess it
would not help us pass more information than the xid does.
I've attached the updated patches.
Regards,
--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com
| Attachment | Content-Type | Size |
|---|---|---|
| v9-0001-Add-an-xid-argument-to-the-logical-decoding-messa.patch | text/x-patch | 20.3 KB |
| v9-0002-Add-a-hook-for-handling-logical-messages-on-subsc.patch | text/x-patch | 121.3 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Stepan Neretin | 2026-11-16 19:13:25 | Assert "target_wal_endrec == divergerec" in pg_rewind |
| Previous Message | Tristan Partin | 2026-11-16 18:59:19 | Re: -Wformat-nonliteral |