Re: Proposal: Conflict log history table for Logical Replication

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Dilip Kumar <dilipbalaut(at)gmail(dot)com>
Cc: shveta malik <shveta(dot)malik(at)gmail(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Proposal: Conflict log history table for Logical Replication
Date: 2026-01-05 11:18:50
Message-ID: CAA4eK1J9Ga5WGSV9H+-rOuxQY6ong6w28N+39+hCfT8irknAbw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Jan 4, 2026 at 5:51 PM Dilip Kumar <dilipbalaut(at)gmail(dot)com> wrote:
>
> On Mon, Dec 29, 2025 at 11:32 AM shveta malik <shveta(dot)malik(at)gmail(dot)com> wrote:
> >
> > On Thu, Dec 25, 2025 at 1:10 PM Dilip Kumar <dilipbalaut(at)gmail(dot)com> wrote:
> > >
> > 5)
> > + /*
> > + * Establish an internal dependency between the conflict log table and the
> > + * subscription. By using DEPENDENCY_INTERNAL, we ensure the table is
> > + * automatically reaped when the subscription is dropped. This also
> > + * prevents the table from being dropped independently unless the
> > + * subscription itself is removed.
> > + */
> > + ObjectAddressSet(myself, RelationRelationId, relid);
> > + ObjectAddressSet(subaddr, SubscriptionRelationId, subid);
> > + recordDependencyOn(&myself, &subaddr, DEPENDENCY_INTERNAL);
> >
> > Now that we have pg_conflict, which is treated similarly to a system
> > catalog, I’m wondering whether we actually need to maintain this
> > dependency to prevent the CLT table or schema from being dropped.
> > Also, given that this currently goes against the convention that a
> > shared object cannot be present in pg_depend, could DropSubscription()
> > and AlterSubscription() instead handle dropping the table explicitly
> > in required scenarios?
>
> I thought about it while implementing the catalog schema, but then
> left as it is considering pg_toast tables also maintain internal
> dependency on the table, having said that, during drop
> subscription/alter subscription we anyway have to explicitly call the
> performDeletion of the table so seems like we are not achieving
> anything by maintaining dependency. Lets see what others have to say
> on this? I prefer removing this dependency because this is an
> exceptional case where we are maintaining dependency from a local
> object to a shared object. And now if we do not have any need for
> this we better get rid of it.
>

The main reason we wanted DEPENDENCY_INTERNAL was to prevent the user
from "breaking" the subscription by dropping the table or its schema.
But now with the introduction of the pg_conflict system schema, we can
avoid that. So, it makes sense to drop the table explicitly where
required. BTW, what happens if one drops the database which has a
pg_conflict schema and a conflict table and then tries to drop the
subscription? Do we need special handling for this if we remove the
dependency stuff?

--
With Regards,
Amit Kapila.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Soumya S Murali 2026-01-05 11:23:53 Re: Allowing ALTER COLUMN TYPE for columns in publication column lists
Previous Message Tender Wang 2026-01-05 11:06:13 Re: Add SPLIT PARTITION/MERGE PARTITIONS commands