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 07:42:56
Message-ID: OS9PR01MB12149D35EA9BE9E588806F5B2F5A62@OS9PR01MB12149.jpnprd01.prod.outlook.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> I found two race conditions wrong remote_xid can be reported for streaming=on
> case.

I also found similar issue that wrong remote_commit_ts can be reported for streaming=on
and PREPARED transaction.

1. insert initial tuples on publisher:
2. Delete a tuple on subscriber:
3. Start a large transaction (T1) to stream the change and PREPARE:
publisher=# BEGIN;
SELECT txid_current();
UPDATE foo
SET b = 'T1-' || repeat('x', 20000000)
WHERE a = 1;
BEGIN
txid_current
--------------
697
(1 row)
publisher=*# PREPARE TRANSACTION 'test';

4. Do COMMIT PREPARED. CLT can be updated here.
5. Check the conflict log table on subscriber. remote_commit_ts should be appeared
but NULL can be reported. If the apply worker had applied other transactions before,
the timetstamp could be reported.

subscriber=# SELECT remote_xid, remote_commit_ts FROM pg_conflict.pg_conflict_log_16392;
remote_xid | remote_commit_ts
------------+------------------
697 |
(1 row)

IIUC it's because remote_commit_ts is not updated in apply_handle_stream_prepare().
We should follow what apply_handle_stream_commit() does.

Best regards,
Hayato Kuroda
FUJITSU LIMITED

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kyotaro Horiguchi 2026-08-18 07:46:44 Re: pgbench: \gset and \aset should store SQL NULL as the null value
Previous Message pgsql-hackers 2026-08-18 07:05:45 Re: Unsafe qual pushdown through DISTINCT with simple CASE expressions