diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2017-02-27 17:05:49 -0500 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2017-03-12 16:28:30 -0400 |
commit | ae2518adace4ba7ed6a16eba6943bff6ea4ade10 (patch) | |
tree | ce1879e6aa1cec6f16dcd6d7596834d4a4b31ad6 /src/mongo/s/commands/cluster_drop_database_cmd.cpp | |
parent | 04b8ed12d08affcb06e88c8a2b4398628ae0aa62 (diff) | |
download | mongo-ae2518adace4ba7ed6a16eba6943bff6ea4ade10.tar.gz |
SERVER-22611 Sharding catalog cache refactor
Diffstat (limited to 'src/mongo/s/commands/cluster_drop_database_cmd.cpp')
-rw-r--r-- | src/mongo/s/commands/cluster_drop_database_cmd.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/mongo/s/commands/cluster_drop_database_cmd.cpp b/src/mongo/s/commands/cluster_drop_database_cmd.cpp index f86cf073273..178fc5f36bc 100644 --- a/src/mongo/s/commands/cluster_drop_database_cmd.cpp +++ b/src/mongo/s/commands/cluster_drop_database_cmd.cpp @@ -40,9 +40,7 @@ #include "mongo/s/client/shard_registry.h" #include "mongo/s/commands/cluster_commands_common.h" #include "mongo/s/commands/sharded_command_processing.h" -#include "mongo/s/config.h" #include "mongo/s/grid.h" -#include "mongo/s/sharding_raii.h" #include "mongo/util/log.h" namespace mongo { @@ -93,17 +91,19 @@ public: auto scopedDistLock = uassertStatusOK(catalogClient->getDistLockManager()->lock( opCtx, dbname, "dropDatabase", DistLockManager::kDefaultLockTimeout)); + auto const catalogCache = Grid::get(opCtx)->catalogCache(); + // Refresh the database metadata so it kicks off a full reload - Grid::get(opCtx)->catalogCache()->invalidate(dbname); + catalogCache->purgeDatabase(dbname); - auto scopedDbStatus = ScopedShardDatabase::getExisting(opCtx, dbname); + auto dbInfoStatus = catalogCache->getDatabase(opCtx, dbname); - if (scopedDbStatus == ErrorCodes::NamespaceNotFound) { + if (dbInfoStatus == ErrorCodes::NamespaceNotFound) { result.append("info", "database does not exist"); return true; } - uassertStatusOK(scopedDbStatus.getStatus()); + uassertStatusOK(dbInfoStatus.getStatus()); catalogClient->logChange(opCtx, "dropDatabase.start", @@ -111,16 +111,15 @@ public: BSONObj(), ShardingCatalogClient::kMajorityWriteConcern); - auto const db = scopedDbStatus.getValue().db(); + auto& dbInfo = dbInfoStatus.getValue(); // Drop the database's collections from metadata 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(opCtx, db->getPrimaryId(), dbname); + _dropDatabaseFromShard(opCtx, dbInfo.primaryId(), dbname); // Drop the database from each of the remaining shards { @@ -146,7 +145,7 @@ public: } // Invalidate the database so the next access will do a full reload - Grid::get(opCtx)->catalogCache()->invalidate(dbname); + catalogCache->purgeDatabase(dbname); catalogClient->logChange( opCtx, "dropDatabase", dbname, BSONObj(), ShardingCatalogClient::kMajorityWriteConcern); |