diff --git a/src/backend/replication/logical/decode.c b/src/backend/replication/logical/decode.c index 78b9ca48c7..05b9c41e88 100644 --- a/src/backend/replication/logical/decode.c +++ b/src/backend/replication/logical/decode.c @@ -629,11 +629,13 @@ DecodeCommit(LogicalDecodingContext *ctx, XLogRecordBuffer *buf, /* * If the COMMIT record has invalidation messages, it could have catalog - * changes. We check if it's in the list of the initial running transactions - * and then mark it as containing catalog change. + * changes. It is possible that we didn't mark this transaction as + * containing catalog changes when the decoding starts from a commit record + * without decoding the transaction's other changes. So, we ensure to mark + * such transactions as containing catalog change. * * This must be done before SnapBuildCommitTxn() so that we can include - * catalog change transactions to the historic snapshot. + * these transactions in the historic snapshot. */ if (parsed->xinfo & XACT_XINFO_HAS_INVALS) SnapBuildInitialXactSetCatalogChanges(ctx->snapshot_builder, diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c index 2585922dad..3cdee00b9b 100644 --- a/src/backend/replication/logical/snapbuild.c +++ b/src/backend/replication/logical/snapbuild.c @@ -253,10 +253,10 @@ static bool ExportInProgress = false; /* * Array of transactions and subtransactions that were running when * the xl_running_xacts record that we decoded first was written. - * The array is sorted in xidComparator order. Xids are only removed - * from the array when decoding xl_running_xacts record, and then - * the array eventually becomes an empty. This array is allocated in - * builder->context so its lifetime is the same as the snapshot builder. + * The array is sorted in xidComparator order. We remove Xids from + * this array when they become old enough to matter. This array is + * allocated in builder->context so its lifetime is the same as the + * snapshot builder. * * We rely on HEAP2_NEW_CID records and XACT_INVALIDATIONS to know * if the transaction has changed the catalog, and that information @@ -2095,8 +2095,9 @@ CheckPointSnapBuild(void) } /* - * If the given xid is in the list of the initial running xacts, we mark both it - * and its subtransactions as containing catalog changes if not yet. + * If the given xid is in the list of the initial running xacts, we mark the + * transaction and its subtransactions as containing catalog changes. See + * comments */ void SnapBuildInitialXactSetCatalogChanges(SnapBuild *builder, TransactionId xid,