diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2017-01-31 17:26:34 -0500 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2017-02-27 15:39:56 -0500 |
commit | 989a4a90143da181232dabaf777e69c27ebd9295 (patch) | |
tree | 716cadf9beb1d22e88d245bf12d67a3ff1a85675 /src | |
parent | 922af1c49e772a737e6714c0471cc7bb495731be (diff) | |
download | mongo-989a4a90143da181232dabaf777e69c27ebd9295.tar.gz |
SERVER-27382 Remove usage of DBConfig::reload from ChunkManagerTargeter
(cherry picked from commit a82df5012ee9c1d48197af81abc921f717227323)
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/s/chunk_manager_targeter.cpp | 27 | ||||
-rw-r--r-- | src/mongo/s/chunk_manager_targeter.h | 2 |
2 files changed, 11 insertions, 18 deletions
diff --git a/src/mongo/s/chunk_manager_targeter.cpp b/src/mongo/s/chunk_manager_targeter.cpp index 2c07c609cee..d8304521175 100644 --- a/src/mongo/s/chunk_manager_targeter.cpp +++ b/src/mongo/s/chunk_manager_targeter.cpp @@ -38,9 +38,9 @@ #include "mongo/db/operation_context.h" #include "mongo/db/query/canonical_query.h" #include "mongo/db/query/collation/collation_index_key.h" +#include "mongo/s/catalog/catalog_cache.h" #include "mongo/s/chunk.h" #include "mongo/s/client/shard_registry.h" -#include "mongo/s/config.h" #include "mongo/s/grid.h" #include "mongo/s/shard_key_pattern.h" #include "mongo/s/sharding_raii.h" @@ -763,15 +763,19 @@ Status ChunkManagerTargeter::refreshIfNeeded(OperationContext* txn, bool* wasCha } Status ChunkManagerTargeter::refreshNow(OperationContext* txn, RefreshType refreshType) { + if (refreshType == RefreshType_ReloadDatabase) { + Grid::get(txn)->catalogCache()->invalidate(_nss.db().toString()); + } + + // Try not to spam the configs + refreshBackoff(); + auto dbStatus = ScopedShardDatabase::getOrCreate(txn, _nss.db()); if (!dbStatus.isOK()) { return dbStatus.getStatus(); } - auto scopedDb = std::move(dbStatus.getValue()); - - // Try not to spam the configs - refreshBackoff(); + const auto& scopedDb = dbStatus.getValue(); // TODO: Improve synchronization and make more explicit if (refreshType == RefreshType_RefreshChunkManager) { @@ -782,19 +786,10 @@ Status ChunkManagerTargeter::refreshNow(OperationContext* txn, RefreshType refre } catch (const DBException& ex) { return Status(ErrorCodes::UnknownError, ex.toString()); } - - scopedDb.db()->getChunkManagerOrPrimary(txn, _nss.ns(), _manager, _primary); - } else if (refreshType == RefreshType_ReloadDatabase) { - try { - // Dumps the db info, reloads it all, synchronization between threads happens internally - scopedDb.db()->reload(txn); - } catch (const DBException& ex) { - return Status(ErrorCodes::UnknownError, ex.toString()); - } - - scopedDb.db()->getChunkManagerOrPrimary(txn, _nss.ns(), _manager, _primary); } + scopedDb.db()->getChunkManagerOrPrimary(txn, _nss.ns(), _manager, _primary); + return Status::OK(); } diff --git a/src/mongo/s/chunk_manager_targeter.h b/src/mongo/s/chunk_manager_targeter.h index 949718f0258..cea71318458 100644 --- a/src/mongo/s/chunk_manager_targeter.h +++ b/src/mongo/s/chunk_manager_targeter.h @@ -108,8 +108,6 @@ public: private: // Different ways we can refresh metadata enum RefreshType { - // No refresh is needed - RefreshType_None, // The version has gone up, but the collection hasn't been dropped RefreshType_RefreshChunkManager, // The collection may have been dropped, so we need to reload the db |