summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEsha Maharishi <esha.maharishi@mongodb.com>2016-08-05 12:24:10 -0400
committerEsha Maharishi <esha.maharishi@mongodb.com>2016-08-11 11:03:11 -0400
commitb4b3cda7501f1d4a292f3b02e13631fae8d4de7f (patch)
treebd4b804487576861447164dd379b9105e28c6dad
parentd1d26b71ca0ac0b20f868dc8accd26769d5fd169 (diff)
downloadmongo-b4b3cda7501f1d4a292f3b02e13631fae8d4de7f.tar.gz
SERVER-25417 flesh out log messages in ShardingState::initializeShardingAwarenessIfNeeded
-rw-r--r--src/mongo/db/s/sharding_state.cpp39
-rw-r--r--src/mongo/db/s/sharding_state.h6
2 files changed, 28 insertions, 17 deletions
diff --git a/src/mongo/db/s/sharding_state.cpp b/src/mongo/db/s/sharding_state.cpp
index 04097e28e84..a68a2d1231b 100644
--- a/src/mongo/db/s/sharding_state.cpp
+++ b/src/mongo/db/s/sharding_state.cpp
@@ -593,11 +593,14 @@ Status ShardingState::initializeShardingAwarenessIfNeeded(OperationContext* txn)
}
return reloadShardRegistryUntilSuccess(txn);
} else {
- // Warn if --overrideShardIdentity is used but *not* started with --shardsvr.
+ // Error if --overrideShardIdentity is used but *not* started with --shardsvr.
if (!serverGlobalParams.overrideShardIdentity.isEmpty()) {
- warning() << "Not started with --shardsvr, but a shardIdentity document was "
- "provided through --overrideShardIdentity: "
- << serverGlobalParams.overrideShardIdentity;
+ return {
+ ErrorCodes::InvalidOptions,
+ str::stream()
+ << "Not started with --shardsvr, but a shardIdentity document was provided "
+ "through --overrideShardIdentity: "
+ << serverGlobalParams.overrideShardIdentity};
}
return Status::OK();
}
@@ -608,14 +611,14 @@ Status ShardingState::initializeShardingAwarenessIfNeeded(OperationContext* txn)
// inserted).
else {
if (!serverGlobalParams.overrideShardIdentity.isEmpty()) {
- return {ErrorCodes::InvalidOptions,
- str::stream() << "--overrideShardIdentity is only allowed in sharded "
- "queryableBackupMode. If not in queryableBackupMode, edit the "
- "shardIdentity document by starting the server *without* "
- "--shardsvr, manually updating the shardIdentity document in "
- "the "
- << NamespaceString::kConfigCollectionNamespace.toString()
- << " collection, and restarting the server with --shardsvr."};
+ return {
+ ErrorCodes::InvalidOptions,
+ str::stream() << "--overrideShardIdentity is only allowed in sharded "
+ "queryableBackupMode. If not in queryableBackupMode, you can edit "
+ "the shardIdentity document by starting the server *without* "
+ "--shardsvr, manually updating the shardIdentity document in the "
+ << NamespaceString::kConfigCollectionNamespace.toString()
+ << " collection, and restarting the server with --shardsvr."};
}
// Load the shardIdentity document from disk.
@@ -635,7 +638,9 @@ Status ShardingState::initializeShardingAwarenessIfNeeded(OperationContext* txn)
if (shardIdentityBSON.isEmpty()) {
warning() << "Started with --shardsvr, but no shardIdentity document was found on "
"disk in "
- << NamespaceString::kConfigCollectionNamespace;
+ << NamespaceString::kConfigCollectionNamespace
+ << ". This most likely means this server has not yet been added to a "
+ "sharded cluster.";
return Status::OK();
}
auto swShardIdentity = ShardIdentityType::fromBSON(shardIdentityBSON);
@@ -682,8 +687,8 @@ StatusWith<ChunkVersion> ShardingState::_refreshMetadata(
}
}
- // The _configServerTickets serializes this process such that only a small number of threads can
- // try to refresh at the same time
+ // The _configServerTickets serializes this process such that only a small number of threads
+ // can try to refresh at the same time
_configServerTickets.waitForTicket();
TicketHolderReleaser needTicketFrom(&_configServerTickets);
@@ -713,8 +718,8 @@ StatusWith<ChunkVersion> ShardingState::_refreshMetadata(
}
}
- // Exclusive collection lock needed since we're now potentially changing the metadata, and don't
- // want reads/writes to be ongoing
+ // Exclusive collection lock needed since we're now potentially changing the metadata, and
+ // don't want reads/writes to be ongoing
ScopedTransaction transaction(txn, MODE_IX);
AutoGetCollection autoColl(txn, nss, MODE_IX, MODE_X);
diff --git a/src/mongo/db/s/sharding_state.h b/src/mongo/db/s/sharding_state.h
index 209d8754a34..c959592c866 100644
--- a/src/mongo/db/s/sharding_state.h
+++ b/src/mongo/db/s/sharding_state.h
@@ -251,6 +251,12 @@ public:
*/
void setScheduleCleanupFunctionForTest(RangeDeleterCleanupNotificationFunc fn);
+ /**
+ * If started with --shardsvr, initializes sharding awareness from the shardIdentity document
+ * on disk, if there is one.
+ * If started with --shardsvr in queryableBackupMode, initializes sharding awareness from the
+ * shardIdentity document passed through the --overrideShardIdentity startup parameter.
+ */
Status initializeShardingAwarenessIfNeeded(OperationContext* txn);
private: