diff options
-rw-r--r-- | jstests/serverless/initial_sync_change_collection.js | 5 | ||||
-rw-r--r-- | src/mongo/db/change_stream_change_collection_manager.cpp | 8 |
2 files changed, 12 insertions, 1 deletions
diff --git a/jstests/serverless/initial_sync_change_collection.js b/jstests/serverless/initial_sync_change_collection.js index 8910c742a50..6f3b0128ef6 100644 --- a/jstests/serverless/initial_sync_change_collection.js +++ b/jstests/serverless/initial_sync_change_collection.js @@ -96,5 +96,8 @@ const endOplogTimestamp = oplogDocs.at(-1).ts; // the 'startOplogTimestamp' to the 'endOplogTimestamp' must be exactly the same. verifyChangeCollectionEntries(secondary, startOplogTimestamp, endOplogTimestamp); -replSetTest.stopSet(); +// The state of the change collection after the initial sync is not consistent with the primary. +// This is because the change collection's data is never cloned to the secondary, only it's creation +// is cloned. As such, we will skip the db hash check on the change collection. +replSetTest.stopSet(undefined /* signal */, undefined /* forRestart */, {skipCheckDBHashes: true}); })(); diff --git a/src/mongo/db/change_stream_change_collection_manager.cpp b/src/mongo/db/change_stream_change_collection_manager.cpp index e6aaf3e86f8..ca2735db03c 100644 --- a/src/mongo/db/change_stream_change_collection_manager.cpp +++ b/src/mongo/db/change_stream_change_collection_manager.cpp @@ -154,6 +154,14 @@ private: if (auto dropFieldElem = objectFieldElem["drop"_sd]) { return dropFieldElem.String() != NamespaceString::kChangeCollectionName; } + + // Do not write the change collection's own 'create' oplog entry. This is + // because the secondaries will not be able to capture this oplog entry and as + // such, will result in inconsistent state of the change collection in the + // primary and the secondary. + if (auto createFieldElem = objectFieldElem["create"_sd]) { + return createFieldElem.String() != NamespaceString::kChangeCollectionName; + } } } |