summaryrefslogtreecommitdiff
path: root/src/mongo/db/s/config
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2021-04-07 09:05:46 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-04-08 16:18:18 +0000
commit6fc3aec96786f0f3f8afd90b83de2486decccd35 (patch)
tree7b1f58be0e039b64a2b444f580417af74ac4c2fd /src/mongo/db/s/config
parentfd6a8c685088f7e5552f1feb17b6e64530adb755 (diff)
downloadmongo-6fc3aec96786f0f3f8afd90b83de2486decccd35.tar.gz
SERVER-53412 Add assertion that '_configsvrDropCollection/Database' can only run in FCV 4.4
Diffstat (limited to 'src/mongo/db/s/config')
-rw-r--r--src/mongo/db/s/config/configsvr_drop_collection_command.cpp11
-rw-r--r--src/mongo/db/s/config/configsvr_drop_database_command.cpp19
2 files changed, 26 insertions, 4 deletions
diff --git a/src/mongo/db/s/config/configsvr_drop_collection_command.cpp b/src/mongo/db/s/config/configsvr_drop_collection_command.cpp
index 89a9cb351ff..cd4b09c1e43 100644
--- a/src/mongo/db/s/config/configsvr_drop_collection_command.cpp
+++ b/src/mongo/db/s/config/configsvr_drop_collection_command.cpp
@@ -34,6 +34,7 @@
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/client.h"
#include "mongo/db/commands.h"
+#include "mongo/db/commands/feature_compatibility_version.h"
#include "mongo/db/operation_context.h"
#include "mongo/db/repl/read_concern_args.h"
#include "mongo/db/s/drop_collection_legacy.h"
@@ -42,6 +43,9 @@
namespace mongo {
namespace {
+using FeatureCompatibility = ServerGlobalParams::FeatureCompatibility;
+using FCVersion = FeatureCompatibility::Version;
+
/**
* Internal sharding command run on config servers to drop a collection from a database.
*/
@@ -107,6 +111,13 @@ public:
<< cmdObj,
opCtx->getWriteConcern().wMode == WriteConcernOptions::kMajority);
+ FixedFCVRegion fcvRegion(opCtx);
+
+ uassert(ErrorCodes::CommandNotSupported,
+ "The _configsvrDropCollection command is only supported under feature "
+ "compatibility version 4.4",
+ fcvRegion == FCVersion::kFullyDowngradedTo44);
+
dropCollectionLegacy(opCtx, nss);
return true;
diff --git a/src/mongo/db/s/config/configsvr_drop_database_command.cpp b/src/mongo/db/s/config/configsvr_drop_database_command.cpp
index f3df551d59e..346abbf8144 100644
--- a/src/mongo/db/s/config/configsvr_drop_database_command.cpp
+++ b/src/mongo/db/s/config/configsvr_drop_database_command.cpp
@@ -29,21 +29,25 @@
#define MONGO_LOGV2_DEFAULT_COMPONENT ::mongo::logv2::LogComponent::kSharding
+#include "mongo/platform/basic.h"
+
#include "mongo/db/api_parameters.h"
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/client.h"
#include "mongo/db/commands.h"
+#include "mongo/db/commands/feature_compatibility_version.h"
#include "mongo/db/operation_context.h"
#include "mongo/db/repl/repl_client_info.h"
-#include "mongo/db/repl/replication_coordinator.h"
#include "mongo/db/s/drop_database_legacy.h"
#include "mongo/s/catalog/type_database.h"
-#include "mongo/util/scopeguard.h"
// TODO (SERVER-54879): Remove this command entirely after 5.0 branches
namespace mongo {
namespace {
+using FeatureCompatibility = ServerGlobalParams::FeatureCompatibility;
+using FCVersion = FeatureCompatibility::Version;
+
/**
* Internal sharding command run on config servers to drop a database.
*/
@@ -86,14 +90,14 @@ public:
return Status::OK();
}
- std::string parseNs(const std::string& dbname, const BSONObj& cmdObj) const {
+ std::string parseNs(const std::string& dbname, const BSONObj& cmdObj) const override {
return cmdObj.firstElement().str();
}
bool run(OperationContext* opCtx,
const std::string& dbname_unused,
const BSONObj& cmdObj,
- BSONObjBuilder& result) {
+ BSONObjBuilder& result) override {
uassert(ErrorCodes::IllegalOperation,
"_configsvrDropDatabase can only be run on config servers",
serverGlobalParams.clusterRole == ClusterRole::ConfigServer);
@@ -114,6 +118,13 @@ public:
<< cmdObj,
opCtx->getWriteConcern().wMode == WriteConcernOptions::kMajority);
+ FixedFCVRegion fcvRegion(opCtx);
+
+ uassert(ErrorCodes::CommandNotSupported,
+ "The _configsvrDropDatabase command is only supported under feature compatibility "
+ "version 4.4",
+ fcvRegion == FCVersion::kFullyDowngradedTo44);
+
dropDatabaseLegacy(opCtx, dbname);
repl::ReplClientInfo::forClient(opCtx->getClient()).setLastOpToSystemLastOpTime(opCtx);
return true;