| From: | shveta malik <shveta(dot)malik(at)gmail(dot)com> |
|---|---|
| To: | Dilip Kumar <dilipbalaut(at)gmail(dot)com> |
| Cc: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, vignesh C <vignesh21(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>, shveta malik <shveta(dot)malik(at)gmail(dot)com> |
| Subject: | Re: Proposal: Conflict log history table for Logical Replication |
| Date: | 2026-10-07 09:18:11 |
| Message-ID: | CAJpy0uDWLfz_VQF2=oHQR4sTzB1cb-s7zXfxMzjZrGRse+uqMw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Sun, Oct 4, 2026 at 2:31 PM Dilip Kumar <dilipbalaut(at)gmail(dot)com> wrote:
>
>
> And without fix shared as a v77-0003 [1], this would error out with
> below error[2], I have explained the reason [1]. I have added a
> testcase in 035_conflicts.pl file in v79-0003 patch for this issue.
>
Thanks for the patches. I have resumed reviewing this thread. I think
the size cap added in v79-0002 does not fully prevent the >1GB json
value it is meant to guard against.
In build_index_key_json(), the cap is checked against the stored size
(rawsize), but what actually gets appended is the type's output text,
escaped by escape_json(). In some cases, the output can be far larger
than the storage, and the ratio is not the small factor the comment
atop CONFLICT_MAX_VALUE_SIZE assumes. I have attached a test case to
reproduce the problem. In the test, we use composite types such as:
CREATE TYPE ri_n0 AS (f text);
then
CREATE TYPE ri_n1 AS (f ri_n0);
CREATE TYPE ri_n2 AS (f ri_n1);
... going up to ri_n25.
ri_n25 is then used as the key column of a table.
Then we insert a row whose replica identity is
ROW(...ROW(repeat('"',10))...)::ri_n25. On disk it is stored in this
compact nested form (not the expanded one, ~620 bytes), but in
build_index_key_json(), OidOutputFunctionCall (i.e. record_out)
recurses through all 25 nested levels, to expand the value into its
text form, which grows beyond 800MB, and escaping it then exceeds 1GB.
So durng escape_json() post OidOutputFunctionCall(), apply worker
errors out with:
ERROR: string buffer exceeds maximum allowed length (1073741823 bytes)
I have attached the complete steps to reproduce the issue, as well as
a patch to fix the problem. Please review.
thanks
Shveta
| Attachment | Content-Type | Size |
|---|---|---|
| json_ri_output_overflow.txt | text/plain | 1.1 KB |
| 0001-Fix-Ri-output-overflow-bug.patch | application/octet-stream | 1.3 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Alvaro Herrera | 2026-10-07 09:26:24 | Re: REPACK (CONCURRENTLY) can't complete after ~105M concurrent updates/deletes |
| Previous Message | Michael Banck | 2026-10-07 09:15:37 | Low frequency AIO checksum corruption on buildfarm member fruitcrow / GNU Hurd |