summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2019-11-20 11:23:38 +0000
committerevergreen <evergreen@mongodb.com>2019-11-20 11:23:38 +0000
commit13c3960a0c30e05d8a3b25e5bf9669e268933ec7 (patch)
tree5cc7c130011d570046cf2aeddd37640c19fc9c6c
parent69fb4bd8c149fc814cf0e9a37ca14b4391062a54 (diff)
downloadmongo-13c3960a0c30e05d8a3b25e5bf9669e268933ec7.tar.gz
SERVER-43403 disallow drops and renames during index creation
-rw-r--r--src/mongo/db/commands/SConscript1
-rw-r--r--src/mongo/db/commands/create_indexes.cpp4
2 files changed, 5 insertions, 0 deletions
diff --git a/src/mongo/db/commands/SConscript b/src/mongo/db/commands/SConscript
index 7464bc5b2b0..bbc0780edb6 100644
--- a/src/mongo/db/commands/SConscript
+++ b/src/mongo/db/commands/SConscript
@@ -280,6 +280,7 @@ env.Library(
],
LIBDEPS_PRIVATE=[
'$BUILD_DIR/mongo/base',
+ '$BUILD_DIR/mongo/db/background',
'$BUILD_DIR/mongo/db/catalog/catalog_helpers',
'$BUILD_DIR/mongo/db/catalog/collection_catalog_helper',
'$BUILD_DIR/mongo/db/catalog/collection_query_info',
diff --git a/src/mongo/db/commands/create_indexes.cpp b/src/mongo/db/commands/create_indexes.cpp
index 94636ac0247..ada7fa43a7f 100644
--- a/src/mongo/db/commands/create_indexes.cpp
+++ b/src/mongo/db/commands/create_indexes.cpp
@@ -666,6 +666,10 @@ bool runCreateIndexesWithCoordinator(OperationContext* opCtx,
std::string& errmsg,
BSONObjBuilder& result) {
const NamespaceString ns(CommandHelpers::parseNsCollectionRequired(dbname, cmdObj));
+
+ // Disallows drops and renames on this namespace.
+ BackgroundOperation backgroundOp(ns.ns());
+
uassertStatusOK(userAllowedWriteNS(ns));
// Disallow users from creating new indexes on config.transactions since the sessions code