Re: BUG #18280: logical decoding build wrong snapshot for subtransactions

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>
Cc: feichanghong <feichanghong(at)qq(dot)com>, pgsql-bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #18280: logical decoding build wrong snapshot for subtransactions
Date: 2024-01-24 09:18:57
Message-ID: CAA4eK1KULrO8H4nzosuDiV0tAVHpHLuFFcvQA7JB125Qbhc6OQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, Jan 23, 2024 at 6:03 PM Hayato Kuroda (Fujitsu)
<kuroda(dot)hayato(at)fujitsu(dot)com> wrote:
>
> Thanks for reporting the bug. I could reproduce the issue with your reproducer.
> I agreed your point.
>
> > Thanks, your analysis sounds correct to me. BTW, I think this should
> > occur only in 15 and 14 because in prior branches we didn't check if
> > the xact has catalog changes before marking its subxacts. From 16
> > onwards, we already accurately serialize the xacts and subxacts that
> > have made any catalog changes, so this problem shouldn't be there. Can
> > you please once verify the same?
>
> I tested PG16-PG13 and got below result. As you said, only the ERROR happened
> only on PG14 and PG15.
>

While looking closely at the test result, I wondered how the following
part of test "s0_begin" "s0_truncate" "s1_checkpoint" "s1_get_changes"
"s0_insert_part" "s1_get_changes" "s0_commit" can see the insert when
the containing transaction is not yet committed. Then, I found it is
because the insert is performed from session 1 due to way it is
declared.

session "s1"
...
step "s1_get_changes" { SELECT data FROM
pg_logical_slot_get_changes('isolation_slot', NULL, NULL,
'skip-empty-xacts', '1', 'include-xids', '0'); }
+step "s0_insert_part" { INSERT INTO tbl1_part VALUES (1); }

I think this session should be performed from seesion-1 and we need
one more get_changes() call to see the problem. I have modified the
test accordingly and also changed the comments. See the attached and
let me know what you people think.

--
With Regards,
Amit Kapila.

Attachment Content-Type Size
v2-0001-Fix-catalog-lookup-due-to-wrong-snapshot-for-subt.patch application/octet-stream 7.2 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Christoph Berg 2024-01-24 09:20:48 Re: Misleading/inaccurate error message from pg_basebackup
Previous Message PG Bug reporting form 2024-01-24 06:43:49 BUG #18308: SQL query information_schema metadata got error: server process was terminated by signal 11: Segment