diff options
author | Jordi Olivares Provencio <jordi.olivares-provencio@mongodb.com> | 2022-04-26 08:54:30 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-05-31 09:14:05 +0000 |
commit | 6247d20bcdfa80984c135583fbb501a0b46cc380 (patch) | |
tree | 0b48d3e77ae58b5d933e521b258ccbe6ecda2c45 | |
parent | 97ce6056dfab8b48139d6e7918e6ea66178da879 (diff) | |
download | mongo-6247d20bcdfa80984c135583fbb501a0b46cc380.tar.gz |
SERVER-65426 Verify if there's an existing view when creating a collection
(cherry picked from commit c9d4924f3b0628166bac7a464f78f3addefacd3b)
-rw-r--r-- | src/mongo/db/catalog/collection_catalog.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/ops/write_ops_exec.cpp | 3 |
2 files changed, 4 insertions, 3 deletions
diff --git a/src/mongo/db/catalog/collection_catalog.cpp b/src/mongo/db/catalog/collection_catalog.cpp index e0c4f41afad..4e5df27b592 100644 --- a/src/mongo/db/catalog/collection_catalog.cpp +++ b/src/mongo/db/catalog/collection_catalog.cpp @@ -1259,7 +1259,9 @@ void CollectionCatalog::_ensureNamespaceDoesNotExist(OperationContext* opCtx, 5725003, "Conflicted registering namespace, already have a view with the same namespace", "nss"_attr = nss); - throw WriteConflictException(); + uasserted(ErrorCodes::NamespaceExists, + "Conflicted registering namespace, already have a view with the same " + "namespace"); } } } diff --git a/src/mongo/db/ops/write_ops_exec.cpp b/src/mongo/db/ops/write_ops_exec.cpp index 0310cb7cd5e..6fd7e2200c7 100644 --- a/src/mongo/db/ops/write_ops_exec.cpp +++ b/src/mongo/db/ops/write_ops_exec.cpp @@ -238,8 +238,7 @@ void makeCollection(OperationContext* opCtx, const NamespaceString& ns) { assertCanWrite_inlock(opCtx, ns); if (!CollectionCatalog::get(opCtx)->lookupCollectionByNamespace( - opCtx, - ns)) { // someone else may have beat us to it. + opCtx, ns)) { // someone else may have beat us to it. uassertStatusOK(userAllowedCreateNS(opCtx, ns)); OperationShardingState::ScopedAllowImplicitCollectionCreate_UNSAFE unsafeCreateCollection(opCtx); |