diff options
author | Gregory Noma <gregory.noma@gmail.com> | 2022-01-24 20:10:27 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-01-24 21:24:12 +0000 |
commit | 2d23c2650eee84f5bcbb9bef5acdad4a583d488b (patch) | |
tree | 1d5d632b12e088b2b06e97f043eda0ea9527c2fb /src/mongo/db/s/create_collection_coordinator.cpp | |
parent | ba25336add6ed39d8a5dc3d0371e3e34730aa83d (diff) | |
download | mongo-2d23c2650eee84f5bcbb9bef5acdad4a583d488b.tar.gz |
SERVER-62454 Add `collectionUUID` parameter to `shardCollection` command
Diffstat (limited to 'src/mongo/db/s/create_collection_coordinator.cpp')
-rw-r--r-- | src/mongo/db/s/create_collection_coordinator.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/mongo/db/s/create_collection_coordinator.cpp b/src/mongo/db/s/create_collection_coordinator.cpp index ad201f5caf4..f705250c347 100644 --- a/src/mongo/db/s/create_collection_coordinator.cpp +++ b/src/mongo/db/s/create_collection_coordinator.cpp @@ -34,6 +34,7 @@ #include "mongo/db/audit.h" #include "mongo/db/auth/authorization_session.h" #include "mongo/db/cancelable_operation_context.h" +#include "mongo/db/catalog/collection_uuid_mismatch.h" #include "mongo/db/catalog/create_collection.h" #include "mongo/db/catalog_raii.h" #include "mongo/db/commands/create_gen.h" @@ -473,6 +474,7 @@ ExecutorFuture<void> CreateCollectionCoordinator::_runImpl( getCollation(opCtx, nss(), _doc.getCollation()).second, _doc.getUnique().value_or(false))) { _result = createCollectionResponseOpt; + _checkCollectionUUIDMismatch(opCtx); // The collection was already created and commited but there was a // stepdown after the commit. RecoverableCriticalSectionService::get(opCtx) @@ -511,6 +513,7 @@ ExecutorFuture<void> CreateCollectionCoordinator::_runImpl( } } + _checkCollectionUUIDMismatch(opCtx); _createPolicy(opCtx); _createCollectionAndIndexes(opCtx); @@ -675,6 +678,11 @@ void CreateCollectionCoordinator::_checkCommandArguments(OperationContext* opCtx } } +void CreateCollectionCoordinator::_checkCollectionUUIDMismatch(OperationContext* opCtx) const { + AutoGetCollection coll{opCtx, nss(), MODE_IS}; + checkCollectionUUIDMismatch(opCtx, coll.getCollection(), _doc.getCollectionUUID()); +} + void CreateCollectionCoordinator::_createCollectionAndIndexes(OperationContext* opCtx) { LOGV2_DEBUG( 5277903, 2, "Create collection _createCollectionAndIndexes", "namespace"_attr = nss()); |