Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-26715

mongo shell does not correctly initialize its own min and max wire version

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.4.0-rc3
    • Affects Version/s: None
    • Component/s: Shell
    • Labels:
    • Fully Compatible
    • ALL
    • Hide

      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) :
      
      Show
      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) :
    • Platforms 2016-11-21

      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.

            Assignee:
            jonathan.reams@mongodb.com Jonathan Reams
            Reporter:
            david.storch@mongodb.com David Storch
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: