diff options
author | Esha Maharishi <esha.maharishi@mongodb.com> | 2016-08-11 21:36:54 -0400 |
---|---|---|
committer | Esha Maharishi <esha.maharishi@mongodb.com> | 2016-08-11 21:36:54 -0400 |
commit | 62ae8e41416c8dde5c09b9c7ce63b88bd36b3f6b (patch) | |
tree | 09f7b719bb5df31b24a295a6238be4231ed2a7b3 /src/mongo | |
parent | d1223a8ad44d6bc91766f0bd05a08820cdb1fdea (diff) | |
download | mongo-62ae8e41416c8dde5c09b9c7ce63b88bd36b3f6b.tar.gz |
Revert "SERVER-22663 Make --shardsvr required for a mongod to be used as a shard"
This reverts commit d1223a8ad44d6bc91766f0bd05a08820cdb1fdea.
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/commands/dbcommands.cpp | 29 | ||||
-rw-r--r-- | src/mongo/db/s/operation_sharding_state.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/s/sharding_state.cpp | 3 | ||||
-rw-r--r-- | src/mongo/db/s/sharding_state.h | 14 | ||||
-rw-r--r-- | src/mongo/shell/replsettest.js | 7 |
5 files changed, 18 insertions, 41 deletions
diff --git a/src/mongo/db/commands/dbcommands.cpp b/src/mongo/db/commands/dbcommands.cpp index 3bd645c8cfd..bd848af59b6 100644 --- a/src/mongo/db/commands/dbcommands.cpp +++ b/src/mongo/db/commands/dbcommands.cpp @@ -1433,30 +1433,19 @@ void Command::execCommand(OperationContext* txn, oss.initializeShardVersion(commandNS, extractedFields[kShardVersionFieldIdx]); auto shardingState = ShardingState::get(txn); - - if (oss.hasShardVersion()) { - if (serverGlobalParams.clusterRole != ClusterRole::ShardServer) { - uassertStatusOK( - {ErrorCodes::IllegalOperation, - "Cannot accept sharding commands if not started with --shardsvr"}); - } else if (!shardingState->enabled()) { - // TODO(esha): Once 3.4 ships, we no longer need to support initializing - // sharding awareness through commands, so just reject all sharding commands. - if (!shardingState->commandInitializesShardingAwareness( - request.getCommandName().toString())) { - uassertStatusOK({ErrorCodes::IllegalOperation, - str::stream() - << "Received a command with sharding chunk version " - "information but this node is not sharding aware: " - << request.getCommandArgs().jsonString()}); - } - } - } - if (shardingState->enabled()) { // TODO(spencer): Do this unconditionally once all nodes are sharding aware // by default. uassertStatusOK(shardingState->updateConfigServerOpTimeFromMetadata(txn)); + } else { + massert( + 34422, + str::stream() + << "Received a command with sharding chunk version information but this " + "node is not sharding aware: " + << request.getCommandArgs().jsonString(), + !oss.hasShardVersion() || + ChunkVersion::isIgnoredVersion(oss.getShardVersion(commandNS))); } } diff --git a/src/mongo/db/s/operation_sharding_state.cpp b/src/mongo/db/s/operation_sharding_state.cpp index 5d0cad65b52..97991dc27f8 100644 --- a/src/mongo/db/s/operation_sharding_state.cpp +++ b/src/mongo/db/s/operation_sharding_state.cpp @@ -54,6 +54,11 @@ 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; } @@ -84,6 +89,7 @@ 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 d5e57b8357d..a68a2d1231b 100644 --- a/src/mongo/db/s/sharding_state.cpp +++ b/src/mongo/db/s/sharding_state.cpp @@ -118,9 +118,6 @@ 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 28eb837c215..c959592c866 100644 --- a/src/mongo/db/s/sharding_state.h +++ b/src/mongo/db/s/sharding_state.h @@ -259,16 +259,6 @@ 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; @@ -382,10 +372,6 @@ 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; diff --git a/src/mongo/shell/replsettest.js b/src/mongo/shell/replsettest.js index dcb49984fe9..570ef6d13c2 100644 --- a/src/mongo/shell/replsettest.js +++ b/src/mongo/shell/replsettest.js @@ -454,14 +454,13 @@ var ReplSetTest = function(opts) { * Starts each node in the replica set with the given options. * * @param options - The options passed to {@link MongoRunner.runMongod} - * @param restart - If true and no options are provided, each node is restarted with its - * existing options. */ - this.startSet = function(options, restart) { + this.startSet = function(options) { print("ReplSetTest starting set"); + var nodes = []; for (var n = 0; n < this.ports.length; n++) { - nodes.push(this.start(n, options, restart)); + nodes.push(this.start(n, options)); } this.nodes = nodes; |