v18-0001-amit.diff.txt

text/plain

Filename: v18-0001-amit.diff.txt
Type: text/plain
Part: 0
Message: Re: long-standing data loss bug in initial sync of logical replication
diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c
index 16acb506141..fd1a3e75b29 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -739,7 +739,8 @@ SnapBuildDistributeSnapshotAndInval(SnapBuild *builder, XLogRecPtr lsn, Transact
 	/*
 	 * Iterate through all toplevel transactions. This can include
 	 * subtransactions which we just don't yet know to be that, but that's
-	 * fine, they will just get an unnecessary snapshot queued.
+	 * fine, they will just get an unnecessary snapshot and invalidations
+	 * queued.
 	 */
 	dlist_foreach(txn_i, &builder->reorder->toplevel_by_lsn)
 	{
@@ -787,12 +788,12 @@ SnapBuildDistributeSnapshotAndInval(SnapBuild *builder, XLogRecPtr lsn, Transact
 								 builder->snapshot);
 
 		/*
-		 * Add invalidation messages to the reorder buffer of inprogress
+		 * Add invalidation messages to the reorder buffer of in-progress
 		 * transactions except the current committed transaction, for which we
 		 * will execute invalidations at the end.
 		 *
 		 * It is required, otherwise, we will end up using the stale catcache
-		 * contents built by the current transaction even after its decoding
+		 * contents built by the current transaction even after its decoding,
 		 * which should have been invalidated due to concurrent catalog
 		 * changing transaction.
 		 */
@@ -1071,8 +1072,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
 		SnapBuildSnapIncRefcount(builder->snapshot);
 
 		/*
-		 * add a new catalog snapshot and invalidations messages to all
-		 * currently running transactions
+		 * Add a new catalog snapshot and invalidations messages to all
+		 * currently running transactions.
 		 */
 		SnapBuildDistributeSnapshotAndInval(builder, lsn, xid);
 	}