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

feichanghong <feichanghong@qq.com>

From: feichanghong <feichanghong@qq.com>
To: feichanghong <feichanghong@qq.com>, pgsql-bugs <pgsql-bugs@lists.postgresql.org>
Date: 2024-01-10T13:56:00Z
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.

Attachments

&gt; SnapBuildXidSetCatalogChanges (introduced in 272248a) skipping the check for
&gt; the sub-transactions when the parent transaction has been marked as
&gt; containing catalog changes should be the root cause of the problem.




My fix is to remove the ReorderBufferXidHasCatalogChanges condition from the SnapBuildXidSetCatalogChanges function. This approach has a false positive; the subtransactions that didn't change catalog to the snapshot are also added to the commit list. But that won't be a problem since we use snapshot built during decoding only to read system catalogs, as 272248a's commit message says.


The&nbsp;attached&nbsp;patch&nbsp;has&nbsp;been&nbsp;verified&nbsp;to&nbsp;resolve&nbsp;the&nbsp;mentioned&nbsp;issue.


Best regards.


Alibaba Cloud Computing Ltd.