summaryrefslogtreecommitdiff
path: root/src/mongo/db/s/shardsvr_drop_database_command.cpp
diff options
context:
space:
mode:
authorTommaso Tocci <tommaso.tocci@mongodb.com>2021-01-27 16:56:13 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-01-29 10:46:28 +0000
commita1c14013a1bb88b32105f997c5035bf28597ac75 (patch)
tree158c5e730696bd32652bc0eb9aac0650da87fe00 /src/mongo/db/s/shardsvr_drop_database_command.cpp
parentd8fb94ae2b7b4dbd21c56c06a54ba908ac081694 (diff)
downloadmongo-a1c14013a1bb88b32105f997c5035bf28597ac75.tar.gz
SERVER-52811 Implement the new drop database path in _shardsvrDropDatabase
Diffstat (limited to 'src/mongo/db/s/shardsvr_drop_database_command.cpp')
-rw-r--r--src/mongo/db/s/shardsvr_drop_database_command.cpp32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/mongo/db/s/shardsvr_drop_database_command.cpp b/src/mongo/db/s/shardsvr_drop_database_command.cpp
index 516bb6a2b79..98bdcfed9ad 100644
--- a/src/mongo/db/s/shardsvr_drop_database_command.cpp
+++ b/src/mongo/db/s/shardsvr_drop_database_command.cpp
@@ -29,12 +29,18 @@
#define MONGO_LOGV2_DEFAULT_COMPONENT ::mongo::logv2::LogComponent::kSharding
+#include "mongo/platform/basic.h"
+
#include "mongo/db/auth/authorization_session.h"
+#include "mongo/db/catalog/collection_catalog.h"
#include "mongo/db/commands.h"
+#include "mongo/db/curop.h"
+#include "mongo/db/s/drop_database_coordinator.h"
#include "mongo/db/s/sharding_state.h"
#include "mongo/logv2/log.h"
#include "mongo/s/grid.h"
#include "mongo/s/request_types/sharded_ddl_commands_gen.h"
+#include "mongo/s/sharded_collections_ddl_parameters_gen.h"
namespace mongo {
namespace {
@@ -86,7 +92,31 @@ public:
<< opCtx->getWriteConcern().wMode,
opCtx->getWriteConcern().wMode == WriteConcernOptions::kMajority);
- return dropDatabaseLegacy(opCtx, request().getDbName());
+ const auto dbName = request().getDbName();
+
+ if (!feature_flags::gShardingFullDDLSupport.isEnabled(
+ serverGlobalParams.featureCompatibility) ||
+ feature_flags::gDisableIncompleteShardingDDLSupport.isEnabled(
+ serverGlobalParams.featureCompatibility)) {
+
+ LOGV2_DEBUG(
+ 5281110, 1, "Running legacy drop database procedure", "database"_attr = dbName);
+ return dropDatabaseLegacy(opCtx, dbName);
+ }
+
+ LOGV2_DEBUG(
+ 5281111, 1, "Running new drop database procedure", "database"_attr = dbName);
+
+ // Since this operation is not directly writing locally we need to force its db
+ // profile level increase in order to be logged in "<db>.system.profile"
+ CurOp::get(opCtx)->raiseDbProfileLevel(
+ CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(dbName));
+
+ auto dropDatabaseCoordinator = std::make_shared<DropDatabaseCoordinator>(opCtx, dbName);
+ dropDatabaseCoordinator->run(opCtx).get();
+
+ // The following response can be omitted once 5.0 became last LTS
+ return Response();
}
private: