Re: Proposal: Conflict log history table for Logical Replication

From: vignesh C <vignesh21(at)gmail(dot)com>
To: Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>
Cc: "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Zhijie Hou <houzhijie22(at)gmail(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, shveta malik <shveta(dot)malik(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>, Peter Smith <smithpb2250(at)gmail(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, shveta malik <shvetamalik(at)gmail(dot)com>
Subject: Re: Proposal: Conflict log history table for Logical Replication
Date: 2026-11-26 02:56:57
Message-ID: CALDaNm3WFKGcVOjTZmOf6GLVF6x9mAh+m+9pk9VsTM6ChGGkAg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 25 Nov 2026 at 17:23, Nisha Moond <nisha(dot)moond412(at)gmail(dot)com> wrote:
>
> Attached v2 patch fixing above as well as other comments from Hou-san at [2].

DROP SUBSCRIPTION ... CASCADE drops the objects that depend on the
subscription's conflict log table (CLT), such as views but sql_drop
event triggers don't see those objects.
CREATE TABLE dropped_log (object_type text, object_identity text);
CREATE FUNCTION log_drops() RETURNS event_trigger LANGUAGE plpgsql AS $$
BEGIN
INSERT INTO dropped_log
SELECT object_type, object_identity FROM pg_event_trigger_dropped_objects();
END $$;
CREATE EVENT TRIGGER log_drops ON sql_drop EXECUTE FUNCTION log_drops();

CREATE SUBSCRIPTION sub1 CONNECTION 'dbname=postgres' PUBLICATION pub1
WITH (connect = false, slot_name = NONE, conflict_log_destination = 'table');
-- <oid> is the subscription's OID
CREATE VIEW v AS SELECT relid FROM pg_conflict.pg_conflict_log_<oid>;

DROP SUBSCRIPTION sub1 CASCADE;
SELECT * FROM dropped_log;
--------------+-----------------
subscription | sub1
(1 row)

The view v was dropped, but it is not in the list.

drop_sub_conflict_log_table() drops the table with
PERFORM_DELETION_INTERNAL. deleteObjectsInList() skips event-trigger
tracking for every object of a deletion when that flag is set
(dependency.c:196, and the comment at line 255). Only the subscription
is reported, because DropSubscription() adds it by itself.

I felt for CASCADE, drop the conflict table without
PERFORM_DELETION_INTERNAL flag like the changes in the attached patch.
Thoughts?

Regards,
Vignesh

Attachment Content-Type Size
drop_subscription_cascade_event_trigger_fix.patch application/octet-stream 1.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2026-11-26 03:01:09 Re: Reducing output size of nodeToString
Previous Message Ajin Cherian 2026-11-26 02:33:32 Wrong relation in apply worker "not updatable" errors for partitions; relcache leak in check_and_init_gencol()