summaryrefslogtreecommitdiff
path: root/src/mongo/s/sharding_initialization.cpp
diff options
context:
space:
mode:
authorRandolph Tan <randolph@10gen.com>2016-04-11 13:03:02 -0400
committerRandolph Tan <randolph@10gen.com>2016-04-20 16:45:23 -0400
commit879d562c1fee80e84d6705efba7e47e714614505 (patch)
treed5f2e4d5ad7eab1fa1b2b0a64b7c880742379278 /src/mongo/s/sharding_initialization.cpp
parent0e45dbdbfda0ff381308b37d75235cad1da3db54 (diff)
downloadmongo-879d562c1fee80e84d6705efba7e47e714614505.tar.gz
SERVER-22647 opObserver on shard mongod to initialize sharding state on insert to admin.system.version
Diffstat (limited to 'src/mongo/s/sharding_initialization.cpp')
-rw-r--r--src/mongo/s/sharding_initialization.cpp56
1 files changed, 33 insertions, 23 deletions
diff --git a/src/mongo/s/sharding_initialization.cpp b/src/mongo/s/sharding_initialization.cpp
index 1be0d0ae45d..71640889e5f 100644
--- a/src/mongo/s/sharding_initialization.cpp
+++ b/src/mongo/s/sharding_initialization.cpp
@@ -133,8 +133,7 @@ std::unique_ptr<TaskExecutorPool> makeTaskExecutorPool(std::unique_ptr<NetworkIn
return executorPool;
}
-Status initializeGlobalShardingState(OperationContext* txn,
- const ConnectionString& configCS,
+Status initializeGlobalShardingState(const ConnectionString& configCS,
uint64_t maxChunkSizeBytes,
bool isMongos) {
if (configCS.type() == ConnectionString::INVALID) {
@@ -164,6 +163,7 @@ Status initializeGlobalShardingState(OperationContext* txn,
shardRegistry.get(),
HostAndPort(getHostName(), serverGlobalParams.port));
+ auto rawCatalogManager = catalogManager.get();
grid.init(
std::move(catalogManager),
stdx::make_unique<CatalogCache>(),
@@ -173,14 +173,38 @@ Status initializeGlobalShardingState(OperationContext* txn,
std::move(executorPool),
networkPtr);
+ Status status = rawCatalogManager->startup();
+ if (!status.isOK()) {
+ return status;
+ }
+
+ return Status::OK();
+}
+
+} // namespace
+
+Status initializeGlobalShardingStateForMongos(const ConnectionString& configCS,
+ uint64_t maxChunkSizeBytes) {
+ return initializeGlobalShardingState(configCS, maxChunkSizeBytes, true);
+}
+
+Status initializeGlobalShardingStateForMongod(const ConnectionString& configCS) {
+ return initializeGlobalShardingState(configCS, ChunkSizeSettingsType::kDefaultMaxChunkSizeBytes, false);
+}
+
+Status reloadShardRegistryUntilSuccess(OperationContext* txn) {
+ if (serverGlobalParams.configsvrMode != CatalogManager::ConfigServerMode::NONE) {
+ return Status::OK();
+ }
+
while (!inShutdown()) {
- try {
- Status status = grid.catalogManager(txn)->startup(txn);
- uassertStatusOK(status);
+ auto stopStatus = txn->checkForInterruptNoAssert();
+ if (!stopStatus.isOK()) {
+ return stopStatus;
+ }
- if (serverGlobalParams.configsvrMode == CatalogManager::ConfigServerMode::NONE) {
- grid.shardRegistry()->reload(txn);
- }
+ try {
+ grid.shardRegistry()->reload(txn);
return Status::OK();
} catch (const DBException& ex) {
Status status = ex.toStatus();
@@ -198,21 +222,7 @@ Status initializeGlobalShardingState(OperationContext* txn,
}
}
- return Status::OK();
-}
-
-} // namespace
-
-Status initializeGlobalShardingStateForMongos(OperationContext* txn,
- const ConnectionString& configCS,
- uint64_t maxChunkSizeBytes) {
- return initializeGlobalShardingState(txn, configCS, maxChunkSizeBytes, true);
-}
-
-Status initializeGlobalShardingStateForMongod(OperationContext* txn,
- const ConnectionString& configCS) {
- return initializeGlobalShardingState(
- txn, configCS, ChunkSizeSettingsType::kDefaultMaxChunkSizeBytes, false);
+ return {ErrorCodes::ShutdownInProgress, "aborting shard loading attempt"};
}
} // namespace mongo