-
Type: Bug
-
Resolution: Won't Do
-
Priority: Major - P3
-
None
-
Affects Version/s: 4.4.18
-
Component/s: None
-
None
-
Storage Execution
-
ALL
-
Execution Team 2023-05-01
This issue started affecting several drivers when connectionId was implemented in the return of the hello() command.
The general ticket of the driver issue is this:
https://jira.mongodb.org/browse/DRIVERS-2503
The problem with connectioId is that the type returned can change, causing exceptions on the driver side. An example is the following ticket:
https://jira.mongodb.org/browse/CDRIVER-4593
Mongo can return the connectionId as int, int64, or double. In the ticket above, tcpdump is showing the double type.
When looking at Mongo code we can see that appendNumber function:
https://github.com/mongodb/mongo/blob/r4.4.14/src/mongo/s/commands/cluster_is_master_cmd.cpp#L189
result.appendNumber("maxBsonObjectSize", BSONObjMaxUserSize); result.appendNumber("maxMessageSizeBytes", MaxMessageSizeBytes); result.appendNumber("maxWriteBatchSize", write_ops::kMaxWriteBatchSize); result.appendDate("localTime", jsTime()); result.append("logicalSessionTimeoutMinutes", localLogicalSessionTimeoutMinutes); result.appendNumber("connectionId", opCtx->getClient()->getConnectionId());
If we look at the appendNumber:
https://github.com/mongodb/mongo/blob/86b88644407bc94cf4358434d221703d234d75c7/db/jsobj.h
We can see:
/** * appendNumber is a series of method for appending the smallest sensible type * mostly for JS */ void appendNumber( const string& fieldName , int n ){ append( fieldName.c_str() , n ); } void appendNumber( const string& fieldName , double d ){ append( fieldName.c_str() , d ); } void appendNumber( const string& fieldName , long long l ){ static long long maxInt = (int)pow( 2.0 , 30.0 ); static long long maxDouble = (long long)pow( 2.0 , 40.0 ); if ( l < maxInt ) append( fieldName.c_str() , (int)l ); else if ( l < maxDouble ) append( fieldName.c_str() , (double)l ); else append( fieldName.c_str() , l ); }
So, Mongo needs to decide where to fix this issue. If this is expected behavior then this fix needs to be accepted:
https://jira.mongodb.org/browse/CDRIVER-4593
Otherwise, if it is a server issue, the upstream code needs to provide a single type to return the connectionId to avoid these driver exceptions.
From what I see in this bug, it gives the impression no one was expecting Mongo running for so long without the need to be restarted.
- causes
-
CDRIVER-4593 C Driver fails to validate double type connectionId during handshake process
- Closed
- related to
-
DRIVERS-2503 ConnectionId returned in heartbeats may be int64
- Implementing
-
SERVER-43762 tighten the overload set for BSONObjBuilder::appendNumber
- Closed