aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAmit Kapila <akapila@postgresql.org>2024-01-29 10:42:41 +0530
committerAmit Kapila <akapila@postgresql.org>2024-01-29 10:42:41 +0530
commitb793a416bfa8448a6be6deeb3b962c1173efa613 (patch)
tree3a9724fd40b59566ca054ff484686a89f970a4e9 /src
parent8b34cff3381a6a1d3c3d97141d468d468d2a2551 (diff)
downloadpostgresql-b793a416bfa8448a6be6deeb3b962c1173efa613.tar.gz
postgresql-b793a416bfa8448a6be6deeb3b962c1173efa613.zip
Fix catalog lookup due to wrong snapshot for subtransactions during decoding.
In commit 272248a0c, we fixed the catalog lookup due to the wrong snapshot for transactions and subtransactions during decoding. We failed to consider the case where top-level xact is already marked as containing catalog change but its subtransaction is not yet marked as containing catalog change even though it contained such a change. This can happen when during decoding, none of the WAL records from the subtransaction was decoded and top-level xact contains a DDL. We fix it by marking the transaction and all its subtransactions as containing catalog changes if the top-level xact contains any catalog change and it is present in the initial running xacts array. This fix is required only for 14 and 15 because in prior branches we already always mark the transaction and all its subtransactions as containing catalog changes in the same case. In 16 and above, we preserve the list of transaction IDs and sub-transaction IDs, that have modified catalogs and are running during snapshot serialization, to the serialized snapshot (see commit 7f13ac8123). Author: Fei Changhong Reviewed-by: Amit Kapila, Hayato Kuroda, Andy Fan Discussion: https://postgr.es/m/18280-4c8060178cb41750@postgresql.org
Diffstat (limited to 'src')
-rw-r--r--src/backend/replication/logical/snapbuild.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c
index 3eaaaac6b3a..39819947c13 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -2126,11 +2126,13 @@ SnapBuildXidSetCatalogChanges(SnapBuild *builder, TransactionId xid, int subxcnt
TransactionId *subxacts, XLogRecPtr lsn)
{
/*
- * Skip if there is no initial running xacts information or the
- * transaction is already marked as containing catalog changes.
+ * Skip if there is no initial running xacts information.
+ *
+ * Even if the transaction has been marked as containing catalog
+ * changes, it cannot be skipped because its subtransactions that
+ * modified the catalog may not be marked.
*/
- if (NInitialRunningXacts == 0 ||
- ReorderBufferXidHasCatalogChanges(builder->reorder, xid))
+ if (NInitialRunningXacts == 0)
return;
if (bsearch(&xid, InitialRunningXacts, NInitialRunningXacts,