summaryrefslogtreecommitdiff
path: root/src/mongo/db/s
diff options
context:
space:
mode:
authorEsha Maharishi <esha.maharishi@mongodb.com>2016-08-11 20:50:01 -0400
committerEsha Maharishi <esha.maharishi@mongodb.com>2016-08-11 21:07:39 -0400
commitd1223a8ad44d6bc91766f0bd05a08820cdb1fdea (patch)
treecbf51e562e432452193d238abd9f13c84db4ebf4 /src/mongo/db/s
parent6c6bf0284642a7fe1138888d6c3044a6f4912468 (diff)
downloadmongo-d1223a8ad44d6bc91766f0bd05a08820cdb1fdea.tar.gz
SERVER-22663 Make --shardsvr required for a mongod to be used as a shard
Diffstat (limited to 'src/mongo/db/s')
-rw-r--r--src/mongo/db/s/operation_sharding_state.cpp6
-rw-r--r--src/mongo/db/s/sharding_state.cpp3
-rw-r--r--src/mongo/db/s/sharding_state.h14
3 files changed, 17 insertions, 6 deletions
diff --git a/src/mongo/db/s/operation_sharding_state.cpp b/src/mongo/db/s/operation_sharding_state.cpp
index 97991dc27f8..5d0cad65b52 100644
--- a/src/mongo/db/s/operation_sharding_state.cpp
+++ b/src/mongo/db/s/operation_sharding_state.cpp
@@ -54,11 +54,6 @@ void OperationShardingState::initializeShardVersion(NamespaceString nss,
const BSONElement& shardVersionElt) {
invariant(!hasShardVersion());
- if (nss.isSystemDotIndexes()) {
- setShardVersion(std::move(nss), ChunkVersion::IGNORED());
- return;
- }
-
if (shardVersionElt.eoo() || shardVersionElt.type() != BSONType::Array) {
return;
}
@@ -89,7 +84,6 @@ ChunkVersion OperationShardingState::getShardVersion(const NamespaceString& nss)
void OperationShardingState::setShardVersion(NamespaceString nss, ChunkVersion newVersion) {
// This currently supports only setting the shard version for one namespace.
invariant(!_hasVersion || _ns == nss);
- invariant(!nss.isSystemDotIndexes() || ChunkVersion::isIgnoredVersion(newVersion));
_ns = std::move(nss);
_shardVersion = std::move(newVersion);
diff --git a/src/mongo/db/s/sharding_state.cpp b/src/mongo/db/s/sharding_state.cpp
index a68a2d1231b..d5e57b8357d 100644
--- a/src/mongo/db/s/sharding_state.cpp
+++ b/src/mongo/db/s/sharding_state.cpp
@@ -118,6 +118,9 @@ void updateShardIdentityConfigStringCB(const string& setName, const string& newC
} // namespace
+const std::set<std::string> ShardingState::_commandsThatInitializeShardingAwareness{
+ "_recvChunkStart", "mergeChunks", "moveChunk", "setShardVersion", "splitChunk"};
+
ShardingState::ShardingState()
: _initializationState(static_cast<uint32_t>(InitializationState::kNew)),
_initializationStatus(Status(ErrorCodes::InternalError, "Uninitialized value")),
diff --git a/src/mongo/db/s/sharding_state.h b/src/mongo/db/s/sharding_state.h
index c959592c866..28eb837c215 100644
--- a/src/mongo/db/s/sharding_state.h
+++ b/src/mongo/db/s/sharding_state.h
@@ -259,6 +259,16 @@ public:
*/
Status initializeShardingAwarenessIfNeeded(OperationContext* txn);
+ /**
+ * Check if a command is one of the whitelisted commands that can be accepted with shardVersion
+ * information before this node is sharding aware, because the command initializes sharding
+ * awareness.
+ */
+ static bool commandInitializesShardingAwareness(const std::string& commandName) {
+ return _commandsThatInitializeShardingAwareness.find(commandName) !=
+ _commandsThatInitializeShardingAwareness.end();
+ }
+
private:
friend class ScopedRegisterMigration;
@@ -372,6 +382,10 @@ private:
// The id for the cluster this shard belongs to.
OID _clusterId;
+ // A whitelist of sharding commands that are allowed when running with --shardsvr but not yet
+ // shard aware, because they initialize sharding awareness.
+ static const std::set<std::string> _commandsThatInitializeShardingAwareness;
+
// Function for initializing the external sharding state components not owned here.
GlobalInitFunc _globalInit;