diff options
-rw-r--r-- | jstests/multiVersion/new_mongos_old_mongod_wire_version_clash.js | 70 | ||||
-rw-r--r-- | src/mongo/rpc/protocol.cpp | 6 |
2 files changed, 3 insertions, 73 deletions
diff --git a/jstests/multiVersion/new_mongos_old_mongod_wire_version_clash.js b/jstests/multiVersion/new_mongos_old_mongod_wire_version_clash.js deleted file mode 100644 index 2bdeafce9f7..00000000000 --- a/jstests/multiVersion/new_mongos_old_mongod_wire_version_clash.js +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Verify that a current mongos, when connected to an old mongod (one that - * implements a different wire-protocol version) reports the resulting failures - * properly. - * - * Note that the precise errors and failure modes caught here are not documented, - * and are not depended upon by deployed systems. If improved error handling - * results in this test failing, this test may be updated to reflect the actual - * error reported. In particular, a change that causes a failure to report - * ErrorCodes.IncompatibleServerVersion here would generally be an improvement. - */ - -(function() { - - "use strict"; - - load('jstests/libs/override_methods/multiversion_override_balancer_control.js'); - - /* Start a ShardingTest with a 'last-stable' mongos so that a 'last-stable' - * shard can be added. (A 'last-stable' shard cannot be added from a - * current mongos because the wire protocol must be presumed different.) - */ - st = new ShardingTest({ - shards: 1, - other: { - mongosOptions: {binVersion: "last-stable"}, - shardOptions: {binVersion: "last-stable"}, - } - }); - - assert.commandWorked(st.s.adminCommand({enableSharding: 'test'})); - assert.commandWorked(st.s.adminCommand({shardCollection: 'test.foo', key: {x: 1}})); - - // Start a current-version mongos. - var newMongos = MongoRunner.runMongos({configdb: st._configDB}); - - // Write commands report failure by returning writeError: - - assert.writeErrorWithCode(ErrorCodes.RemoteResultsUnavailable, - newMongos.getDB('test').foo.insert({x: 1})); - - assert.writeErrorWithCode(ErrorCodes.RemoteResultsUnavailable, - newMongos.getDB('test').foo.update({x: 1}, {x: 1, y: 2})); - - assert.writeErrorWithCode(ErrorCodes.RemoteResultsUnavailable, - newMongos.getDB('test').foo.remove({x: 1})); - - // Query commands, on failure, throw instead: - - var thrownException = assert.throws(function() { - newMongos.getDB('test').foo.find({}).next(); - }); - assert.eq(ErrorCodes.IncompatibleServerVersion, thrownException.code); - - var socketExceptionErrorCode = 11002; - - thrownException = assert.throws(function() { - newMongos.getDB('test').foo.find({x: 1}).count(); - }); - assert.eq(socketExceptionErrorCode, thrownException.code); - - thrownException = assert.throws(function() { - newMongos.getDB('test').foo.aggregate([]); - }); - assert.eq(socketExceptionErrorCode, thrownException.code); - - MongoRunner.stopMongos(newMongos.port); - st.stop(); - -})(); diff --git a/src/mongo/rpc/protocol.cpp b/src/mongo/rpc/protocol.cpp index ad4ec071cbd..90e7ad58389 100644 --- a/src/mongo/rpc/protocol.cpp +++ b/src/mongo/rpc/protocol.cpp @@ -144,7 +144,7 @@ StatusWith<ProtocolSetAndWireVersionInfo> parseProtocolSetFromIsMasterReply( if (minWireVersion < 0 || maxWireVersion < 0 || minWireVersion >= std::numeric_limits<int>::max() || maxWireVersion >= std::numeric_limits<int>::max()) { - return Status(ErrorCodes::IncompatibleServerVersion, + return Status(ErrorCodes::BadValue, str::stream() << "Server min and max wire version have invalid values (" << minWireVersion << "," @@ -186,7 +186,7 @@ Status validateWireVersion(const WireVersionInfo client, const WireVersionInfo s // Server may return bad data. if (server.minWireVersion > server.maxWireVersion) { - return Status(ErrorCodes::IncompatibleServerVersion, + return Status(ErrorCodes::BadValue, str::stream() << "Server min and max wire version are incorrect (" << server.minWireVersion << "," @@ -198,7 +198,7 @@ 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, + return Status(ErrorCodes::BadValue, str::stream() << "Server min and max wire version are incompatible (" << server.minWireVersion << "," |