diff options
author | Dianna Hohensee <dianna.hohensee@10gen.com> | 2018-01-17 10:43:14 -0500 |
---|---|---|
committer | Dianna Hohensee <dianna.hohensee@10gen.com> | 2018-02-16 16:30:44 -0500 |
commit | d1c188b17167f0430f5a8d10e972c0d00a908ba2 (patch) | |
tree | 8ce4510c4ec7507a17a2ad6719cf6695f5149b4b /src/mongo/rpc | |
parent | 902b8552f11697308604823c19d6dbce661fc3d6 (diff) | |
download | mongo-d1c188b17167f0430f5a8d10e972c0d00a908ba2.tar.gz |
SERVER-32635 an old mongos server communicating with a fully upgraded cluster should crash
Diffstat (limited to 'src/mongo/rpc')
-rw-r--r-- | src/mongo/rpc/protocol.cpp | 18 | ||||
-rw-r--r-- | src/mongo/rpc/protocol_test.cpp | 18 |
2 files changed, 26 insertions, 10 deletions
diff --git a/src/mongo/rpc/protocol.cpp b/src/mongo/rpc/protocol.cpp index fe0f9cebfcc..8d4823da8e8 100644 --- a/src/mongo/rpc/protocol.cpp +++ b/src/mongo/rpc/protocol.cpp @@ -211,16 +211,14 @@ Status validateWireVersion(const WireVersionInfo client, const WireVersionInfo s // We assert the invariant that min < max above. if (!(client.minWireVersion <= server.maxWireVersion && client.maxWireVersion >= server.minWireVersion)) { - return Status(ErrorCodes::IncompatibleServerVersion, - str::stream() << "Server min and max wire version are incompatible (" - << server.minWireVersion - << "," - << server.maxWireVersion - << ") with client min wire version (" - << client.minWireVersion - << "," - << client.maxWireVersion - << ")"); + std::string errmsg = str::stream() + << "Server min and max wire version (" << server.minWireVersion << "," + << server.maxWireVersion << ") is incompatible with client min wire version (" + << client.minWireVersion << "," << client.maxWireVersion << ")."; + if (client.maxWireVersion < server.minWireVersion) { + return Status(ErrorCodes::IncompatibleWithUpgradedServer, errmsg); + } + return Status(ErrorCodes::IncompatibleServerVersion, errmsg); } return Status::OK(); diff --git a/src/mongo/rpc/protocol_test.cpp b/src/mongo/rpc/protocol_test.cpp index 1781d9fab2c..ab92e3eeae1 100644 --- a/src/mongo/rpc/protocol_test.cpp +++ b/src/mongo/rpc/protocol_test.cpp @@ -281,4 +281,22 @@ TEST(Protocol, validateWireVersion) { WireVersion::LATEST_WIRE_VERSION - 1); } +// A mongos is unable to communicate with a fully upgraded cluster with a higher wire version. +TEST(Protocol, validateWireVersionFailsForUpgradedServerNode) { + // Server is fully upgraded higher than the latest wire version. + auto msg = + BSON("minWireVersion" << static_cast<int>(WireVersion::FUTURE_WIRE_VERSION_FOR_TESTING) + << "maxWireVersion" + << static_cast<int>(WireVersion::FUTURE_WIRE_VERSION_FOR_TESTING)); + auto swReply = parseProtocolSetFromIsMasterReply(msg); + ASSERT_OK(swReply.getStatus()); + + // The client (this mongos server) only has latest wire version. + ASSERT_EQUALS( + mongo::ErrorCodes::IncompatibleWithUpgradedServer, + validateWireVersion({WireVersion::LATEST_WIRE_VERSION, WireVersion::LATEST_WIRE_VERSION}, + swReply.getValue().version) + .code()); +} + } // namespace |