diff options
Diffstat (limited to 'src/mongo/db/commands.cpp')
-rw-r--r-- | src/mongo/db/commands.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/mongo/db/commands.cpp b/src/mongo/db/commands.cpp index 142037458bb..b2187a0e697 100644 --- a/src/mongo/db/commands.cpp +++ b/src/mongo/db/commands.cpp @@ -49,6 +49,7 @@ #include "mongo/db/client.h" #include "mongo/db/command_generic_argument.h" #include "mongo/db/commands/test_commands_enabled.h" +#include "mongo/db/commands_in_multi_doc_txn_params_gen.h" #include "mongo/db/curop.h" #include "mongo/db/error_labels.h" #include "mongo/db/jsobj.h" @@ -110,8 +111,7 @@ bool checkAuthorizationImplPreParse(OperationContext* opCtx, } // The command names that are allowed in a multi-document transaction. -const StringMap<int> txnCmdWhitelistFCV44 = { - {"create", 1}, {"createIndexes", 1}, {"_configsvrCreateCollection", 1}}; +const StringMap<int> txnCmdWhitelistFCV44 = {{"create", 1}, {"createIndexes", 1}}; const StringMap<int> txnCmdWhitelist = {{"abortTransaction", 1}, {"aggregate", 1}, {"commitTransaction", 1}, @@ -496,6 +496,15 @@ void CommandHelpers::canUseTransactions(const NamespaceString& nss, str::stream() << "Cannot run '" << cmdName << "' in a multi-document transaction.", inTxnWhitelist || inTxnWhitelistFCV44); + if (cmdName == "createCollection"_sd || cmdName == "createIndexes"_sd) { + uassert(ErrorCodes::OperationNotSupportedInTransaction, + str::stream() << "Cannot run '" << cmdName + << "' in a multi-document transaction " + "because creation of collections and " + "indexes inside multi-document transactions is disabled.", + gShouldMultiDocTxnCreateCollectionAndIndexes.load()); + } + const auto dbName = nss.db(); uassert(ErrorCodes::OperationNotSupportedInTransaction, |