summaryrefslogtreecommitdiff
path: root/src/mongo/s/commands/cluster_drop_database_cmd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/s/commands/cluster_drop_database_cmd.cpp')
-rw-r--r--src/mongo/s/commands/cluster_drop_database_cmd.cpp41
1 files changed, 21 insertions, 20 deletions
diff --git a/src/mongo/s/commands/cluster_drop_database_cmd.cpp b/src/mongo/s/commands/cluster_drop_database_cmd.cpp
index f227b4aa89a..f86cf073273 100644
--- a/src/mongo/s/commands/cluster_drop_database_cmd.cpp
+++ b/src/mongo/s/commands/cluster_drop_database_cmd.cpp
@@ -72,7 +72,7 @@ public:
out->push_back(Privilege(ResourcePattern::forDatabaseName(dbname), actions));
}
- bool run(OperationContext* txn,
+ bool run(OperationContext* opCtx,
const std::string& dbname,
BSONObj& cmdObj,
int options,
@@ -86,17 +86,17 @@ public:
"have to pass 1 as db parameter",
cmdObj.firstElement().isNumber() && cmdObj.firstElement().number() == 1);
- auto const catalogClient = Grid::get(txn)->catalogClient(txn);
+ auto const catalogClient = Grid::get(opCtx)->catalogClient(opCtx);
// Lock the database globally to prevent conflicts with simultaneous database
// creation/modification.
auto scopedDistLock = uassertStatusOK(catalogClient->getDistLockManager()->lock(
- txn, dbname, "dropDatabase", DistLockManager::kDefaultLockTimeout));
+ opCtx, dbname, "dropDatabase", DistLockManager::kDefaultLockTimeout));
// Refresh the database metadata so it kicks off a full reload
- Grid::get(txn)->catalogCache()->invalidate(dbname);
+ Grid::get(opCtx)->catalogCache()->invalidate(dbname);
- auto scopedDbStatus = ScopedShardDatabase::getExisting(txn, dbname);
+ auto scopedDbStatus = ScopedShardDatabase::getExisting(opCtx, dbname);
if (scopedDbStatus == ErrorCodes::NamespaceNotFound) {
result.append("info", "database does not exist");
@@ -105,7 +105,7 @@ public:
uassertStatusOK(scopedDbStatus.getStatus());
- catalogClient->logChange(txn,
+ catalogClient->logChange(opCtx,
"dropDatabase.start",
dbname,
BSONObj(),
@@ -114,27 +114,27 @@ public:
auto const db = scopedDbStatus.getValue().db();
// Drop the database's collections from metadata
- for (const auto& nss : getAllShardedCollectionsForDb(txn, dbname)) {
- uassertStatusOK(catalogClient->dropCollection(txn, nss));
+ for (const auto& nss : getAllShardedCollectionsForDb(opCtx, dbname)) {
+ uassertStatusOK(catalogClient->dropCollection(opCtx, nss));
db->markNSNotSharded(nss.ns());
}
// Drop the database from the primary shard first
- _dropDatabaseFromShard(txn, db->getPrimaryId(), dbname);
+ _dropDatabaseFromShard(opCtx, db->getPrimaryId(), dbname);
// Drop the database from each of the remaining shards
{
std::vector<ShardId> allShardIds;
- Grid::get(txn)->shardRegistry()->getAllShardIds(&allShardIds);
+ Grid::get(opCtx)->shardRegistry()->getAllShardIds(&allShardIds);
for (const ShardId& shardId : allShardIds) {
- _dropDatabaseFromShard(txn, shardId, dbname);
+ _dropDatabaseFromShard(opCtx, shardId, dbname);
}
}
// Remove the database entry from the metadata
Status status =
- catalogClient->removeConfigDocuments(txn,
+ catalogClient->removeConfigDocuments(opCtx,
DatabaseType::ConfigNS,
BSON(DatabaseType::name(dbname)),
ShardingCatalogClient::kMajorityWriteConcern);
@@ -146,10 +146,10 @@ public:
}
// Invalidate the database so the next access will do a full reload
- Grid::get(txn)->catalogCache()->invalidate(dbname);
+ Grid::get(opCtx)->catalogCache()->invalidate(dbname);
catalogClient->logChange(
- txn, "dropDatabase", dbname, BSONObj(), ShardingCatalogClient::kMajorityWriteConcern);
+ opCtx, "dropDatabase", dbname, BSONObj(), ShardingCatalogClient::kMajorityWriteConcern);
result.append("dropped", dbname);
return true;
@@ -160,24 +160,25 @@ private:
* Sends the 'dropDatabase' command for the specified database to the specified shard. Throws
* DBException on failure.
*/
- static void _dropDatabaseFromShard(OperationContext* txn,
+ static void _dropDatabaseFromShard(OperationContext* opCtx,
const ShardId& shardId,
const std::string& dbName) {
- const auto dropDatabaseCommandBSON = [txn, &dbName] {
+ const auto dropDatabaseCommandBSON = [opCtx, &dbName] {
BSONObjBuilder builder;
builder.append("dropDatabase", 1);
- if (!txn->getWriteConcern().usedDefault) {
+ if (!opCtx->getWriteConcern().usedDefault) {
builder.append(WriteConcernOptions::kWriteConcernField,
- txn->getWriteConcern().toBSON());
+ opCtx->getWriteConcern().toBSON());
}
return builder.obj();
}();
- const auto shard = uassertStatusOK(Grid::get(txn)->shardRegistry()->getShard(txn, shardId));
+ const auto shard =
+ uassertStatusOK(Grid::get(opCtx)->shardRegistry()->getShard(opCtx, shardId));
auto cmdDropDatabaseResult = uassertStatusOK(shard->runCommandWithFixedRetryAttempts(
- txn,
+ opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
dbName,
dropDatabaseCommandBSON,