Re: Proposal: Conflict log history table for Logical Replication

From: Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>
To: kedar anavardekar <kedar(dot)anavardekar(at)gmail(dot)com>
Cc: Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, shveta malik <shveta(dot)malik(at)gmail(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(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>
Subject: Re: Proposal: Conflict log history table for Logical Replication
Date: 2026-09-25 09:59:24
Message-ID: CABdArM4S3bLbmHT4UOcxxcyZz7EePrZdGezKWzb8NMjpzbtUnw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Sep 25, 2026 at 11:10 AM kedar anavardekar
<kedar(dot)anavardekar(at)gmail(dot)com> wrote:
>
> Hi Nisha,
> Thank you for the patch. I applied it locally, and it compiles successfully.
> I have a few suggestions for consideration for v75. Please treat these
> as optional review comments;
> you and the others can decide whether they are important enough to address.
> Otherwise, feel free to ignore them.
>

Thanks for the review.

>
> > Attached are the updated patches:
> > v75-001: Merged v74 patches 001 and 002 into a single patch.
> > v75-002: Includes the discussed fix, along with TAP tests covering
> > both cases. Also updated the documentation with an example.
> >
>
> 1. Documentation:
> In the example query, could the hard-coded table name:
> pg_conflict.pg_conflict_log_16392
> be replaced with a placeholder such as:
> pg_conflict_log_<subid>
> which is used at other places in doc.
>

The doc already defines the naming rule as pg_conflict_log_<subid> at
the start of the section. I think the examples can use the exact name,
like the hard-coded slot name in [1].
I’ll keep it as is for now and see what others think. Happy to change
it if needed.

> 2. Documentation:
> The documentation says that values larger than 1 kB are omitted.
> However, the implementation
> measures raw detoasted storage size rather than textual output size.
> This distinction may
> matter for custom types, arrays, compressed values, and JSON-like types.
>

Okay, I see it can be confusing. I have reworded the doc section added
patch 002 and added clarification for the 1kB limit.

> 3. Code:
> In:
> + return PointerGetDatum(cstring_to_text_with_len(result.data, result.len));
>
> `result.data` does not appear to be released after the text datum is created.
> Could this accumulate memory when multiple conflicts occur in one
> apply transaction?
>

Far point. ApplyMessageContext resets after each replication message,
so it wouldn't accumulate across a transaction.
But cstring_to_text_with_len() copies, so the buffer is dead
immediately and there's no reason to hold it. Added the pfree().

> 4. Code:
> The name `tuple_table_slot_to_indextup_json` was not immediately clear to me.
> Since the function serializes index key values rather than an index tuple,
> would something like `tuple_table_slot_to_index_key_json` be more descriptive?
>

Okay, function definition is changed, so renamed it as
"build_index_key_json" keeping consistent with neighbouring functions.

> 5. Code:
> Is the following variable necessary? It appears not to be used currently:
> + bool typisvarlena;
>

getTypeOutputInfo() has no NULL check for that out-parameter, hence it
requires &typisvarlena, even though we don't use the result.
~~~

Also added a XXX comment for the uncovered remaining case pointed out in [2].

Attached are the updated patches. Patch 001 has no change from the last version.

[1] https://www.postgresql.org/docs/devel/logical-replication-failover.html
[2] https://www.postgresql.org/message-id/CABdArM7LAtD5a8d%3DURTxxjXjJ4p6uhJVyGXq8QZBAbSPfaictw%40mail.gmail.com

--
Thanks,
Nisha

Attachment Content-Type Size
v76-0001-Implement-the-conflict-insertion-infrastructure-.patch application/x-patch 81.4 KB
v76-0002-Don-t-use-row_to_json-or-record-oversized-values.patch application/x-patch 22.3 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2026-09-25 10:07:13 Re: Reset waitStart when a lock wait fails
Previous Message Hayato Kuroda (Fujitsu) 2026-09-25 09:43:58 RE: Per-table resync for logical replication subscriptions