Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-4593

C Driver fails to validate double type connectionId during handshake process

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.23.3
    • Affects Version/s: 1.23.1, 1.23.2
    • Component/s: libmongoc
    • Labels:

      Summary

      Mongo with higher volume of connections may return connectionId as double during the handshake process. The C(1.23.2) & C++(3.7.x)drivers fail to do a type check for double type connectionId in hello/ismaster response and hence fails to connect to mongo.

      This happens in clusters with a high volume of connections created at a higher rate and/or without any connection pooling mechanism.

      db.isMaster() response from mongo shell:

          db.isMaster()
          {
              "ismaster" : true,
              "msg" : "isdbgrid",
            ...
            ...
            "connectionId" : 3177689371,
            ...
            ...
          }

       

      db.isMaster() response from python driver:

       

      {
         'ok': 1.0, 
         'msg': 'isdbgrid', 
         'ismaster': True, 
         ...
         ...  
         'connectionId': 3177722651.0, <==== double value
         ...
         ...
      }

       

      The C driver fails to check connectionId value, 3177722651.0 with BSON_ITER_HOLDS_INT

      Environment

       C / CXX driver versions:

       

      {"name":"mongoc / mongocxx","version":"1.23.1 / 3.7.0"}
      {"name":"mongoc / mongocxx","version":"1.23.2 / 3.7.0"} 
      

       C / CXX compiler and version:

       

      gcc (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609
      c++11 & c++17
      

       

      Mongo:

      Sharded Cluster with v4.4.14
      

      How to Reproduce

      It's difficult to reproduce the issue. Need to create connections at a higher rate to overflow int32 value of connectionId.

      Temporary Fix

      Restarting the mongo service would reset the connectionId counter.

       

       

        1. connectionId_as_double.png
          connectionId_as_double.png
          458 kB
        2. connectionId_as_int32.png
          connectionId_as_int32.png
          435 kB

            Assignee:
            Unassigned Unassigned
            Reporter:
            konda.valagonda@gmail.com Kondaiah Valagonda
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: