Re: Proposal: Conflict log history table for Logical Replication

From: vignesh C <vignesh21(at)gmail(dot)com>
To: shveta malik <shveta(dot)malik(at)gmail(dot)com>
Cc: "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, Zhijie Hou <houzhijie22(at)gmail(dot)com>, Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, shihao zhong <zhong950419(at)gmail(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, saurabh singh <saurabh(dot)singh214(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Peter Smith <smithpb2250(at)gmail(dot)com>, shveta malik <shvetamalik(at)gmail(dot)com>
Subject: Re: Proposal: Conflict log history table for Logical Replication
Date: 2026-11-26 15:29:44
Message-ID: CALDaNm08sHU=BowHwEdurWt0-XwsAYB0drL_1=S-_XJC4atnqQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, 26 Nov 2026 at 15:25, shveta malik <shveta(dot)malik(at)gmail(dot)com> wrote:
>
> On Thu, Nov 26, 2026 at 2:27 PM Hayato Kuroda (Fujitsu)
> <kuroda(dot)hayato(at)fujitsu(dot)com> wrote:
> >
> > Hi,
> >
> > Here is a comment for v97-0002.
> >
> > I found that conflict log table could be dumped with pg_dump --binary-upgrade --no-subscription,
> > nevertheless the subscription cannot be dumped with them. This is because getSubscriptions()
> > can be skipped by dopt->no_subscriptions but selectDumpableTable() does not.
> > Maybe we should also check the setting here?
>
> +1.
> I see a similar problem with the '--binary-upgrade -n public' option too:
>
> --The subscription is skipped, because it isn't in schema public.
> --The CLT is still dumped, because the patch's CLT branch says to dump
> it in binary-upgrade mode
>
> The same problem exists with '-t .. --binary-upgrade'. I think there
> could be more such combinations too.
>
> I think this check in selectDumpableTable is not enough, it needs more
> checks like: !dopt->no_subscriptions && dopt->include_everything
>
> + if (dopt->binary_upgrade)
> + tbinfo->dobj.dump = DUMP_COMPONENT_DEFINITION | DUMP_COMPONENT_ACL |
> +

The CLT is no longer selected independently in selectDumpableTable().
Instead, CLT tables are selected in selectDumpableNamespace(), in the
branch handling the pg_conflict schema, just like tables in other
schemas. In binary-upgrade mode, the contents of this schema are
dumped only if a new helper, subscriptions_are_dumped(), returns true.
This helper follows the same conditions used to select and dump
subscriptions: a) include_everything is true where the subscription
is left out. b) --no-subscriptions is not specified. c) The user is a
superuser, since getSubscriptions() only issues a warning and returns
for non-superusers. d) The post-data section is included (--section),
since subscriptions are dumped in the post-data section, whereas CLTs
are in the pre-data section. With these checks, --binary-upgrade
combined with --no-subscriptions, -n public, -t ..., or
--section=pre-data excludes the CLT along with its subscription. In
normal mode, nothing related to a CLT is dumped, including its ACL,
because the table is recreated under a new name when the subscription
is restored.

There is one intentional exception: if a CLT is explicitly selected
using -t <clt> or -n pg_conflict, it is dumped like any other table,
even if its subscription is not selected. This behavior is documented
in the code comment and pg_dump.sgml.

The attached v98 version patch has the changes for the same.

This patch also fixes Hou san's comments from [1], Kuroda san's
comments from [2], Shveta's comments from [3].

[1] - https://www.postgresql.org/message-id/2753b65e-9de8-4306-9f96-fc7e8d4c2ef5%40gmail.com
[2] - https://www.postgresql.org/message-id/OS7PR01MB18317716A6C22632EAFC522F7F5422%40OS7PR01MB18317.jpnprd01.prod.outlook.com
[3] - https://www.postgresql.org/message-id/CAJpy0uCoDqf8Tu6OO3LqfYqYjDU4XeApUTsdU%2Bti3CHV00QciQ%40mail.gmail.com

Regards,
Vignesh

Attachment Content-Type Size
v98-0001-Preserve-conflict-log-destination-and-subscripti.patch application/octet-stream 31.5 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2026-11-26 15:35:11 Re: Proposal: Conflict log history table for Logical Replication
Previous Message Zhijie Hou 2026-11-26 15:22:21 Re: Fix assert failure in composite type dependency check for index expr