RE: Proposal: Conflict log history table for Logical Replication

From: "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>
To: 'Dilip Kumar' <dilipbalaut(at)gmail(dot)com>, shveta malik <shveta(dot)malik(at)gmail(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Masahiko Sawada <sawada(dot)mshk(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>, vignesh C <vignesh21(at)gmail(dot)com>, Nisha Moond <nisha(dot)moond412(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-08-18 06:06:16
Message-ID: OS9PR01MB12149AE4F33B25238C8E40D31F5A62@OS9PR01MB12149.jpnprd01.prod.outlook.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Dilip,

I found two race conditions wrong remote_xid can be reported for streaming=on case.
Assuming that there is a table foo (a int PRIMARY KEY, b text).

1. insert initial tuples on publisher:
publisher=# INSERT INTO foo VALUES (1, 'init'), (2, 'init');

2. Delete a tuple on subscriber:
subscriber=# DELETE FROM foo WHERE a = 1;

3. Start a large transaction (T1) to stream the change:
publisher=# BEGIN;
SELECT txid_current();
UPDATE foo
SET b = 'T1-' || repeat('x', 20000000)
WHERE a = 1;
BEGIN
txid_current
--------------
697
(1 row)

4. Start another transaction (T2) and commit immediately
publisher=# BEGIN;
SELECT txid_current();
UPDATE foo SET b = 'T2' WHERE a = 2;
COMMIT;
BEGIN
txid_current
--------------
698
(1 row)

UPDATE 1
COMMIT

5. Commit the T1. It causes the update_missing conflict.
6. Check the conflict log table on subscriber. The remote_xid should be 697, but 698 can be reported.

subscriber=# SELECT remote_xid FROM pg_conflict.pg_conflict_log_16392;
remote_xid
------------
698
(1 row)

IIUC, it's because apply_spooled_messages() does not restore the remote_xid
before applying changes unlike remote_final_lsn. Can we fix here or should be
done separately?

Best regards,
Hayato Kuroda
FUJITSU LIMITED

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2026-08-18 06:07:22 Re: [BUG] hstore integer overflow when constructing large values
Previous Message Xuneng Zhou 2026-08-18 05:59:01 Re: Fix a relcache reference leak in reorderbuffer.c