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.
- is caused by
-
SERVER-75293 Different return types for the connectionId
- Closed
- is related to
-
CDRIVER-4502 libmongoc expects connectionId in hello response to be int32
- Closed