summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorTommaso Tocci <tommaso.tocci@mongodb.com>2021-03-11 10:01:06 +0100
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-03-16 10:48:04 +0000
commitb134809bd5db091c0517ee0fb4378ad420a5c021 (patch)
tree3716fd90ff7c07fd28ef3dc5a7349b0e76138578 /src/mongo/db
parent8bc0340b458b363510bd2caca8c1b6a5790f41db (diff)
downloadmongo-b134809bd5db091c0517ee0fb4378ad420a5c021.tar.gz
SERVER-55145 Make dropping a nonexistent database a noop
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/commands/dbcommands.cpp9
-rw-r--r--src/mongo/db/drop_database.idl16
-rw-r--r--src/mongo/db/s/config/configsvr_drop_database_command.cpp7
-rw-r--r--src/mongo/db/s/drop_database_legacy.cpp10
-rw-r--r--src/mongo/db/s/drop_database_legacy.h2
-rw-r--r--src/mongo/db/s/shardsvr_drop_database_command.cpp9
6 files changed, 11 insertions, 42 deletions
diff --git a/src/mongo/db/commands/dbcommands.cpp b/src/mongo/db/commands/dbcommands.cpp
index b6c1790794f..299ebc197c5 100644
--- a/src/mongo/db/commands/dbcommands.cpp
+++ b/src/mongo/db/commands/dbcommands.cpp
@@ -208,15 +208,10 @@ public:
}
Status status = dropDatabase(opCtx, dbName.toString());
- DropDatabaseReply reply;
- if (status == ErrorCodes::NamespaceNotFound) {
- reply.setInfo("database does not exist"_sd);
- } else {
+ if (status != ErrorCodes::NamespaceNotFound) {
uassertStatusOK(status);
- reply.setDropped(request().getDbName());
}
-
- return reply;
+ return {};
}
};
} cmdDropDatabase;
diff --git a/src/mongo/db/drop_database.idl b/src/mongo/db/drop_database.idl
index 65871ce89f8..5083a0d8559 100644
--- a/src/mongo/db/drop_database.idl
+++ b/src/mongo/db/drop_database.idl
@@ -32,20 +32,6 @@ global:
imports:
- "mongo/idl/basic_types.idl"
-structs:
- DropDatabaseReply:
- description: "The dropDatabase command's reply"
- strict: false
- fields:
- dropped:
- description: "The database's name, if it existed and was dropped"
- type: string
- optional: true
- info:
- description: "May provide information on dropDatabase's outcome"
- type: string
- optional: true
-
commands:
dropDatabase:
description: "Parser for the dropDatabase command"
@@ -55,4 +41,4 @@ commands:
cpp_name: DropDatabase
strict: true
api_version: "1"
- reply_type: DropDatabaseReply
+ reply_type: OkReply
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 de258fab32d..f725a778f68 100644
--- a/src/mongo/db/s/config/configsvr_drop_database_command.cpp
+++ b/src/mongo/db/s/config/configsvr_drop_database_command.cpp
@@ -113,11 +113,8 @@ public:
<< cmdObj,
opCtx->getWriteConcern().wMode == WriteConcernOptions::kMajority);
- auto reply = dropDatabaseLegacy(opCtx, dbname);
- if (!reply.getDropped()) {
- repl::ReplClientInfo::forClient(opCtx->getClient()).setLastOpToSystemLastOpTime(opCtx);
- }
- reply.serialize(&result);
+ dropDatabaseLegacy(opCtx, dbname);
+ repl::ReplClientInfo::forClient(opCtx->getClient()).setLastOpToSystemLastOpTime(opCtx);
return true;
}
} configsvrDropDatabaseCmd;
diff --git a/src/mongo/db/s/drop_database_legacy.cpp b/src/mongo/db/s/drop_database_legacy.cpp
index cd257699ce8..ffab770a1aa 100644
--- a/src/mongo/db/s/drop_database_legacy.cpp
+++ b/src/mongo/db/s/drop_database_legacy.cpp
@@ -64,7 +64,7 @@ void dropDatabaseFromShard(OperationContext* opCtx, const ShardId& shardId, Stri
} // namespace
-DropDatabaseReply dropDatabaseLegacy(OperationContext* opCtx, StringData dbName) {
+void dropDatabaseLegacy(OperationContext* opCtx, StringData dbName) {
auto dbDistLock = uassertStatusOK(DistLockManager::get(opCtx)->lock(
opCtx, dbName, "dropDatabase", DistLockManager::kDefaultLockTimeout));
@@ -77,9 +77,7 @@ DropDatabaseReply dropDatabaseLegacy(OperationContext* opCtx, StringData dbName)
dbType =
catalogClient->getDatabase(opCtx, dbName, repl::ReadConcernLevel::kMajorityReadConcern);
} catch (const ExceptionFor<ErrorCodes::NamespaceNotFound>&) {
- DropDatabaseReply reply;
- reply.setInfo("database does not exist"_sd);
- return reply;
+ return;
}
uassertStatusOK(ShardingLogging::get(opCtx)->logChangeChecked(
@@ -131,10 +129,6 @@ DropDatabaseReply dropDatabaseLegacy(OperationContext* opCtx, StringData dbName)
ShardingLogging::get(opCtx)->logChange(
opCtx, "dropDatabase", dbName, BSONObj(), ShardingCatalogClient::kMajorityWriteConcern);
-
- DropDatabaseReply reply;
- reply.setDropped(dbName);
- return reply;
}
} // namespace mongo
diff --git a/src/mongo/db/s/drop_database_legacy.h b/src/mongo/db/s/drop_database_legacy.h
index f03f06c688d..78f0b4d0751 100644
--- a/src/mongo/db/s/drop_database_legacy.h
+++ b/src/mongo/db/s/drop_database_legacy.h
@@ -35,6 +35,6 @@
namespace mongo {
-DropDatabaseReply dropDatabaseLegacy(OperationContext* opCtx, StringData dbName);
+void dropDatabaseLegacy(OperationContext* opCtx, StringData dbName);
} // namespace mongo
diff --git a/src/mongo/db/s/shardsvr_drop_database_command.cpp b/src/mongo/db/s/shardsvr_drop_database_command.cpp
index 617ec9a3eb3..3a4088d01e8 100644
--- a/src/mongo/db/s/shardsvr_drop_database_command.cpp
+++ b/src/mongo/db/s/shardsvr_drop_database_command.cpp
@@ -49,7 +49,6 @@ namespace {
class ShardsvrDropDatabaseCommand final : public TypedCommand<ShardsvrDropDatabaseCommand> {
public:
using Request = ShardsvrDropDatabase;
- using Response = DropDatabaseReply;
std::string help() const override {
return "Internal command, which is exported by the primary sharding server. Do not call "
@@ -68,7 +67,7 @@ public:
public:
using InvocationBase::InvocationBase;
- Response typedRun(OperationContext* opCtx) {
+ void typedRun(OperationContext* opCtx) {
uassertStatusOK(ShardingState::get(opCtx)->canAcceptShardedCommands());
uassert(ErrorCodes::InvalidOptions,
@@ -89,7 +88,8 @@ public:
if (!useNewPath) {
LOGV2_DEBUG(
5281110, 1, "Running legacy drop database procedure", "database"_attr = dbName);
- return dropDatabaseLegacy(opCtx, dbName);
+ dropDatabaseLegacy(opCtx, dbName);
+ return;
}
LOGV2_DEBUG(
@@ -102,9 +102,6 @@ public:
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: