diff options
author | David Storch <david.storch@10gen.com> | 2016-09-21 18:37:43 -0400 |
---|---|---|
committer | David Storch <david.storch@10gen.com> | 2016-09-23 16:19:52 -0400 |
commit | 85a326b84ce1d1009bfbb97dbce934383d802883 (patch) | |
tree | f63254e416d57d6456eeca51fab8b2cb95291c87 | |
parent | 3103bba2a6250f54af065b55763fef7e9e0b49ea (diff) | |
download | mongo-85a326b84ce1d1009bfbb97dbce934383d802883.tar.gz |
SERVER-25158 fail gracefully when attempting to join a cluster with featureCompatibilityVersion 3.4
-rw-r--r-- | src/mongo/client/replica_set_monitor.cpp | 8 | ||||
-rw-r--r-- | src/mongo/s/client/sharding_connection_hook.cpp | 9 | ||||
-rw-r--r-- | src/mongo/s/server.cpp | 6 | ||||
-rw-r--r-- | src/mongo/s/sharding_initialization.cpp | 5 |
4 files changed, 28 insertions, 0 deletions
diff --git a/src/mongo/client/replica_set_monitor.cpp b/src/mongo/client/replica_set_monitor.cpp index 0a471ffd088..8cf534b3fd5 100644 --- a/src/mongo/client/replica_set_monitor.cpp +++ b/src/mongo/client/replica_set_monitor.cpp @@ -835,6 +835,14 @@ HostAndPort Refresher::_refreshUntilMatches(const ReadPreferenceSetting* criteri conn->isMaster(ignoredOutParam, &reply); pingMicros = timer.micros(); conn.done(); // return to pool on success. + } catch (const DBException& ex) { + // If this mongos is being used in an illegal configuration and must be + // upgraded, bubble up the error. + Status status = ex.toStatus(); + if (status == ErrorCodes::MustUpgrade) { + throw; + } + reply = BSONObj(); // should be a no-op but want to be sure } catch (...) { reply = BSONObj(); // should be a no-op but want to be sure } diff --git a/src/mongo/s/client/sharding_connection_hook.cpp b/src/mongo/s/client/sharding_connection_hook.cpp index bb368f443d1..f1db2092a6f 100644 --- a/src/mongo/s/client/sharding_connection_hook.cpp +++ b/src/mongo/s/client/sharding_connection_hook.cpp @@ -159,6 +159,15 @@ void ShardingConnectionHook::onCreate(DBClientBase* conn) { return; } + // Report a useful error message when we are illegally attempting to connect to 3.4 config + // servers in 3.4 feature compatibility mode. + uassert(ErrorCodes::MustUpgrade, + str::stream() << "Using a 3.2 mongos with a cluster that has " + "featureCompatibilityVersion 3.4 is not a supported " + "configuration. See " + "http://dochub.mongodb.org/core/3.4-feature-compatibility.", + configServerModeNumber < 2); + uassert(28785, str::stream() << "Unrecognized configsvr version number: " << configServerModeNumber << ". Expected either 0 or 1", diff --git a/src/mongo/s/server.cpp b/src/mongo/s/server.cpp index e68fd12b66f..2200143c5bd 100644 --- a/src/mongo/s/server.cpp +++ b/src/mongo/s/server.cpp @@ -296,6 +296,12 @@ static ExitCode runMongosServer() { return EXIT_CLEAN; } error() << "Error initializing sharding system: " << status; + + // Exit gracefully if this mongos is being used incorrectly in a mixed 3.2/3.4 cluster. + if (status == ErrorCodes::MustUpgrade) { + dbexit(EXIT_SHARDING_ERROR); + } + return EXIT_SHARDING_ERROR; } diff --git a/src/mongo/s/sharding_initialization.cpp b/src/mongo/s/sharding_initialization.cpp index 36a074742dd..99079c97c8c 100644 --- a/src/mongo/s/sharding_initialization.cpp +++ b/src/mongo/s/sharding_initialization.cpp @@ -199,6 +199,11 @@ Status initializeGlobalShardingState(OperationContext* txn, // retry. return status; } + + if (status == ErrorCodes::MustUpgrade) { + return status; + } + if (status == ErrorCodes::ReplicaSetNotFound) { // ReplicaSetNotFound most likely means we've been waiting for the config replica // set to come up for so long that the ReplicaSetMonitor stopped monitoring the set. |