summaryrefslogtreecommitdiff
path: root/src/mongo/s/commands/cluster_create_cmd.cpp
diff options
context:
space:
mode:
authorMaria van Keulen <maria.vankeulen@mongodb.com>2020-02-06 19:58:42 +0000
committerevergreen <evergreen@mongodb.com>2020-02-06 19:58:42 +0000
commite9fadb78003810c3985edf33e60c618f4a2c2b3e (patch)
tree2829d62ea315f1de26912c3b10c6f5dcaf0f346c /src/mongo/s/commands/cluster_create_cmd.cpp
parentea696eb7a27f18c21223a3ff94d9124f06698af5 (diff)
downloadmongo-e9fadb78003810c3985edf33e60c618f4a2c2b3e.tar.gz
SERVER-45368 Allow collection/index creation inside txns for sharding
This patch ensures unprepared transactions in a sharded cluster can create new collections and indexes.
Diffstat (limited to 'src/mongo/s/commands/cluster_create_cmd.cpp')
-rw-r--r--src/mongo/s/commands/cluster_create_cmd.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/mongo/s/commands/cluster_create_cmd.cpp b/src/mongo/s/commands/cluster_create_cmd.cpp
index d869ce626d1..d1a3fc792fc 100644
--- a/src/mongo/s/commands/cluster_create_cmd.cpp
+++ b/src/mongo/s/commands/cluster_create_cmd.cpp
@@ -138,7 +138,9 @@ public:
uassertStatusOK(response.swResponse);
const auto createStatus =
mongo::getStatusFromCommandResult(response.swResponse.getValue().data);
- if (createStatus == ErrorCodes::NamespaceExists) {
+ if (createStatus == ErrorCodes::NamespaceExists && !opCtx->inMultiDocumentTransaction()) {
+ // NamespaceExists will cause multi-document transactions to implicitly abort, so
+ // mongos should surface this error to the client.
CollectionOptions options = uassertStatusOK(CollectionOptions::parse(cmdObj));
checkCollectionOptions(opCtx, nss, options);
} else {