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

Hayato Kuroda (Fujitsu) <kuroda.hayato@fujitsu.com>

From: "Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>
To: 'Amit Kapila' <amit.kapila16@gmail.com>, feichanghong <feichanghong@qq.com>
Cc: pgsql-bugs <pgsql-bugs@lists.postgresql.org>
Date: 2024-01-23T12:33:32Z
Lists: pgsql-bugs

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Fix catalog lookup due to wrong snapshot for subtransactions during decoding.

  2. Fix catalog lookup with the wrong snapshot during logical decoding.

Dear hackers,

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.

PG16 not happen
PG15 happen
PG14 happen
PG13 not happen

Also, proposed fix could be applied atop REL_14_STABLE and pass the test.

Best Regards,
Hayato Kuroda
FUJITSU LIMITED