Skip to content

Commit

Permalink
SERVER-19543 Don't store a pointer to the CatalogManager in the Shard…
Browse files Browse the repository at this point in the history
…Registry
  • Loading branch information
stbrody committed Aug 13, 2015
1 parent 7de54a8 commit 8753f23
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 15 deletions.
1 change: 0 additions & 1 deletion src/mongo/s/catalog/dist_lock_catalog_impl_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ class DistLockCatalogFixture : public mongo::unittest::Test {
std::move(executor),
network,
configCS);
_shardRegistry->init(&_catalogMgr);
_shardRegistry->startup();

_distLockCatalog = stdx::make_unique<DistLockCatalogImpl>(_shardRegistry.get(), kWTimeout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ void CatalogManagerReplSetTestFixture::setUp() {

auto shardRegistry(stdx::make_unique<ShardRegistry>(
std::move(targeterFactory), std::move(executor), _mockNetwork, configCS));
shardRegistry->init(cm.get());
shardRegistry->startup();

// For now initialize the global grid object. All sharding objects will be accessible
Expand Down
11 changes: 3 additions & 8 deletions src/mongo/s/client/shard_registry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "mongo/s/catalog/type_shard.h"
#include "mongo/s/client/shard.h"
#include "mongo/s/client/shard_connection.h"
#include "mongo/s/grid.h"
#include "mongo/stdx/memory.h"
#include "mongo/stdx/mutex.h"
#include "mongo/util/log.h"
Expand Down Expand Up @@ -72,18 +73,12 @@ ShardRegistry::ShardRegistry(std::unique_ptr<RemoteCommandTargeterFactory> targe
: _targeterFactory(std::move(targeterFactory)),
_executor(std::move(executor)),
_network(network),
_configServerCS(configServerCS),
_catalogManager(nullptr) {
_configServerCS(configServerCS) {
_addConfigShard_inlock();
}

ShardRegistry::~ShardRegistry() = default;

void ShardRegistry::init(CatalogManager* catalogManager) {
invariant(!_catalogManager);
_catalogManager = catalogManager;
}

void ShardRegistry::startup() {
_executor->startup();
}
Expand All @@ -95,7 +90,7 @@ void ShardRegistry::shutdown() {

void ShardRegistry::reload() {
vector<ShardType> shards;
Status status = _catalogManager->getAllShards(&shards);
Status status = grid.catalogManager()->getAllShards(&shards);
massert(13632, "couldn't get updated shard list from config server", status.isOK());

int numShards = shards.size();
Expand Down
4 changes: 0 additions & 4 deletions src/mongo/s/client/shard_registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,6 @@ class ShardRegistry {
// Config server connection string
ConnectionString _configServerCS;

// Catalog manager from which to load the shard information. Not owned and must outlive
// the shard registry object. Should be set once by a call to init() then never modified again.
CatalogManager* _catalogManager;

// Protects the maps below
mutable stdx::mutex _mutex;

Expand Down
4 changes: 4 additions & 0 deletions src/mongo/s/grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ Grid::CatalogManagerGuard Grid::catalogManager(OperationContext* txn) {
return Grid::CatalogManagerGuard(txn, this);
}

Grid::CatalogManagerGuard Grid::catalogManager() {
return Grid::CatalogManagerGuard(nullptr, this);
}

Grid::CatalogManagerGuard::CatalogManagerGuard(OperationContext* txn, Grid* grid) : _grid(grid) {
_grid->_catalogManagerLock.lock_shared();
}
Expand Down
1 change: 1 addition & 0 deletions src/mongo/s/grid.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class Grid {
bool getConfigShouldBalance(OperationContext* txn) const;

Grid::CatalogManagerGuard catalogManager(OperationContext* txn);
Grid::CatalogManagerGuard catalogManager(); // TODO(spencer): remove

CatalogCache* catalogCache() {
return _catalogCache.get();
Expand Down
1 change: 0 additions & 1 deletion src/mongo/s/sharding_initialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ Status initializeGlobalShardingState(const ConnectionString& configCS) {
catalogManager = std::move(catalogManagerLegacy);
}

shardRegistry->init(catalogManager.get());
shardRegistry->startup();
grid.init(std::move(catalogManager),
std::move(shardRegistry),
Expand Down

0 comments on commit 8753f23

Please sign in to comment.