[SERVER-26715] mongo shell does not correctly initialize its own min and max wire version Created: 20/Oct/16  Updated: 19/Nov/16  Resolved: 08/Nov/16

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: None
Fix Version/s: 3.4.0-rc3

Type: Bug Priority: Major - P3
Reporter: David Storch Assignee: Jonathan Reams
Resolution: Done Votes: 0
Labels: platforms-hocr
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

Apply this patch and attempt to connect the shell to mongod:

diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp
index 85344d2..13eca6f 100644
--- a/src/mongo/db/db.cpp
+++ b/src/mongo/db/db.cpp
@@ -508,7 +508,7 @@ void repairDatabasesAndCheckVersion(OperationContext* txn) {
 void _initWireSpec() {
     WireSpec& spec = WireSpec::instance();
     // accept from any version
-    spec.incoming.minWireVersion = RELEASE_2_4_AND_BEFORE;
+    spec.incoming.minWireVersion = AGG_RETURNS_CURSORS;
     spec.incoming.maxWireVersion = COMMANDS_ACCEPT_WRITE_CONCERN;
     // connect to any version
     spec.outgoing.minWireVersion = RELEASE_2_4_AND_BEFORE;

It should fail with a message like this:

2016-10-20T17:04:55.566-0400 W NETWORK  [main] remote host has incompatible wire version: IncompatibleServerVersion: Server min and max wire version are incompatible (1,5) with client min wire version (0,0)
2016-10-20T17:04:55.567-0400 E QUERY    [main] Error: Server min and max wire version are incompatible (1,5) with client min wire version (0,0) :

Sprint: Platforms 2016-11-21
Participants:

 Description   

The wire_version library, which is linked into mongo, mongod, and mongos, has a static singleton instance of WireSpec, which defines the incoming and outgoing wire protocol versions of the process:

https://github.com/mongodb/mongo/blob/81ea77ca8305f6a8783ba29e1a93cafa6be81a50/src/mongo/db/wire_version.cpp#L36

Mongod and mongos both have code for initializing these wire versions:

The mongo shell, however, has no such initialization. The object will be zero-initialized, which means that the shell's range of outgoing wire protocol versions is [0, 0]. This is incorrect, because the shell actually supports range [0, 5]. This bug has not yet manifested because all existing versions of mongod and mongos include 0 in their range of supported incoming wire versions. However, if a future version were to bump the minimum incoming wire version, older versions of the shell would refuse to connect.



 Comments   
Comment by Githook User [ 08/Nov/16 ]

Author:

{u'username': u'jbreams', u'name': u'Jonathan Reams', u'email': u'jbreams@mongodb.com'}

Message: SERVER-26715 Set default values for WireSpec min/max values
Branch: master
https://github.com/mongodb/mongo/commit/96686d8572eea8316eab9675d2dfa3dfce5b998e

Comment by Jonathan Reams [ 07/Nov/16 ]

david.storch, do we want WireSpec to always default to min/max wireversion and not be zero-initialized, or do we want the shell to have a separate initWireSpec function?

Generated at Thu Feb 08 04:12:59 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.