diff options
author | Rishab Joshi <rishab.joshi@mongodb.com> | 2022-09-02 15:35:01 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-09-04 09:26:21 +0000 |
commit | f3def0f3c2d3880bb313e6d2e9dd7f8184e801f6 (patch) | |
tree | 6059b2e723037c493035697f69670cef08dc71a8 | |
parent | 993d08489112ac4527764528f378bbad89af12f7 (diff) | |
download | mongo-f3def0f3c2d3880bb313e6d2e9dd7f8184e801f6.tar.gz |
SERVER-69401 Prohibit writing change collection own "create" oplog entry to itself.
-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; + } } } |