diff options
author | Maria van Keulen <maria@mongodb.com> | 2020-04-08 10:38:29 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-04-14 13:17:46 +0000 |
commit | 8527f47556d07c22c79f79408238e64f7695decf (patch) | |
tree | 9f8b97696c87936323195f4b8571d2131a8aa31e /src/mongo/db | |
parent | 656ee188b8db0c2ed0e00652ec1c0c47b964a795 (diff) | |
download | mongo-8527f47556d07c22c79f79408238e64f7695decf.tar.gz |
SERVER-47400 Disallow createCollection/Indexes on system colls in txns
(cherry picked from commit 76d4548a751a56c8faf1887114685b540203a650)
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/catalog/create_collection.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/commands/create_indexes.cpp | 5 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/mongo/db/catalog/create_collection.cpp b/src/mongo/db/catalog/create_collection.cpp index f2f8d7b516b..1a863962c26 100644 --- a/src/mongo/db/catalog/create_collection.cpp +++ b/src/mongo/db/catalog/create_collection.cpp @@ -209,6 +209,10 @@ Status createCollection(OperationContext* opCtx, !opCtx->inMultiDocumentTransaction()); return _createView(opCtx, nss, collectionOptions, idIndex); } else { + uassert(ErrorCodes::OperationNotSupportedInTransaction, + str::stream() << "Cannot create system collection " << nss.toString() + << " within a transaction.", + !opCtx->inMultiDocumentTransaction() || !nss.isSystem()); return _createCollection(opCtx, nss, collectionOptions, idIndex); } } diff --git a/src/mongo/db/commands/create_indexes.cpp b/src/mongo/db/commands/create_indexes.cpp index dfe7dd3ccb7..3f817295566 100644 --- a/src/mongo/db/commands/create_indexes.cpp +++ b/src/mongo/db/commands/create_indexes.cpp @@ -501,6 +501,11 @@ bool runCreateIndexesWithCoordinator(OperationContext* opCtx, str::stream() << "not allowed to create index on " << ns.ns(), ns != NamespaceString::kSessionTransactionsTableNamespace); + uassert(ErrorCodes::OperationNotSupportedInTransaction, + str::stream() << "Cannot write to system collection " << ns.toString() + << " within a transaction.", + !opCtx->inMultiDocumentTransaction() || !ns.isSystem()); + auto specs = uassertStatusOK( parseAndValidateIndexSpecs(opCtx, ns, cmdObj, serverGlobalParams.featureCompatibility)); auto replCoord = repl::ReplicationCoordinator::get(opCtx); |