Re: Proposal: Conflict log history table for Logical Replication

From: shveta malik <shveta(dot)malik(at)gmail(dot)com>
To: Dilip Kumar <dilipbalaut(at)gmail(dot)com>
Cc: vignesh C <vignesh21(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>, Peter Smith <smithpb2250(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>, shveta malik <shveta(dot)malik(at)gmail(dot)com>
Subject: Re: Proposal: Conflict log history table for Logical Replication
Date: 2026-06-25 06:07:52
Message-ID: CAJpy0uCLPYs1eLNg-=+f9DiDq4EPp6s4F=PpCk51OtsTTszUmg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thanks for v56. A few comments:

0001:
1)
+ * We complain if either the old or new namespaces is a temporary schema,
+ * temporary toast schema, the TOAST schema, or the conflict schema.
*/
void
CheckSetNamespace(Oid oldNspOid, Oid nspOid)

Shall we remove this comment change now as the check has been removed?

2)
+ /*
+ * Conflict log tables are managed by the system to record logical
+ * replication conflicts.
+ */
+ if (IsConflictLogTableNamespace(RelationGetNamespace(rel)))
+ ereport(ERROR,
+ (errcode(ERRCODE_WRONG_OBJECT_TYPE),
+ errmsg("cannot lock rows in the conflict log table \"%s\"",
+ RelationGetRelationName(rel))));

postgres=# SELECT * FROM pg_conflict.pg_conflict_log_16387 for UPDATE;
ERROR: cannot lock rows in the conflict log table "pg_conflict_log_16387"

Why don't we add detail-message here as well, similar to all other cases:
errdetail("Conflict log tables are system-managed tables for logical
replication conflicts.")));

patch-0002
3)
+ SELECT 'pg_conflict.' || relname INTO tab_name
+ FROM pg_class c JOIN pg_subscription s ON c.relname =
'pg_conflict_log_' || s.oid
+ WHERE s.subname = 'regress_conflict_protection_test';

This query runs many times (10-15). Can we save the result into
clt_name and use it everywhere? This will reduce test-size.

SELECT 'pg_conflict.' || relname AS clt_name
FROM pg_class c JOIN pg_subscription s ON c.relname =
'pg_conflict_log_' || s.oid
WHERE s.subname = 'regress_conflict_protection_test'
\gset

DO
BEGIN
EXECUTE 'CREATE TABLE public.conflict_child () INHERITS (' ||
:'clt_name' || ')';
....

DO
BEGIN
EXECUTE 'ALTER TABLE ' || :'clt_name' || ' RENAME COLUMN relname
TO new_relname';
---

4)
We can also add a test for paritioning along with inheritance:
CREATE TABLE clt_partition PARTITION OF
pg_conflict.pg_conflict_log_16387 FOR VALUES FROM ('2026-01-01') TO
('2027-01-01');

thanks
Shveta

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2026-06-25 06:14:35 Re: psql: add tab completion for subscription wal_receiver_timeout
Previous Message Imran Zaheer 2026-06-25 06:06:02 Re: Move system identifier generation to a common helper