[CXX-646] C++ driver does not connect to replica sets when all members specified Created: 04/Aug/15  Updated: 19/Oct/15  Resolved: 16/Oct/15

Status: Closed
Project: C++ Driver
Component/s: API
Affects Version/s: legacy-1.0.3
Fix Version/s: legacy-1.0.6

Type: Bug Priority: Major - P3
Reporter: Steve Ahlgren Assignee: Adam Midvidy
Resolution: Done Votes: 0
Labels: legacy-cxx
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Zip Archive MongoClientDefect.zip    
Issue Links:
Depends

 Description   

We're upgrading from 2.x to 3.0.4 and are having difficulty connecting to a fresh 3.0.4 replica set via the C++ 1.0.3 driver. If the connection string contains just a single member of the set, connection/auth works perfectly, but if all replica set members are specified, auth fails. Using either mongo::DBClientReplicaSet or mongo::ConnectionString::connect results in the same failure behavior.

When multiple members of a set are specified, the driver does not detect that it's connecting to a Mongo 3 instance, and will attempt to use MONGO-CR instead of SCRAM-SHA1. Tracing through the client code, the client is setting its minimum and maximum wireline versions to (0,0) instead of (0,3) when connecting to the 3.0.4 replica set, which then causes it to default to MONGO-CR as its authentication mechanism. If we add code to detect the wireline version after making a connection (as is done by the driver when connecting to a single machine), the authentication type is set correctly and authentication succeeds.

Are we doing something wrong or is this a defect in the driver? FWIW, connecting to the same replica sets with the Python driver works as expected when all members are listed...

A test executable is attached. To build, update the property sheets with the correct locations for boost, mongo, openssl, and gmock. Enable one of the two test methods DISABLED_TestConnectionReplicaSetAuth or DISABLED_TestConnectionReplicaSetConnectionStringAuth to reproduce the issue.



 Comments   
Comment by Githook User [ 16/Oct/15 ]

Author:

{u'username': u'amidvidy', u'name': u'Adam Midvidy', u'email': u'amidvidy@gmail.com'}

Message: CXX-646 add evergreen configuration for running tests with authentication enabled
Branch: legacy
https://github.com/mongodb/mongo-cxx-driver/commit/fd81a3515744ac9fc3ae50d4d13f864416d4e8bb

Comment by Githook User [ 16/Oct/15 ]

Author:

{u'username': u'amidvidy', u'name': u'Adam Midvidy', u'email': u'amidvidy@gmail.com'}

Message: CXX-646 authenticate with SCRAM against 3.0+ replicaSets
Branch: legacy
https://github.com/mongodb/mongo-cxx-driver/commit/b645a445ccee545d3bf0fbd554719f6d8d0924d7

Comment by Githook User [ 16/Oct/15 ]

Author:

{u'username': u'amidvidy', u'name': u'Adam Midvidy', u'email': u'amidvidy@gmail.com'}

Message: CXX-646 use mongodb_auth_uri when available so we can authenticate
Branch: legacy
https://github.com/mongodb/mongo-cxx-driver/commit/e64d267fc9f53fe1f7cc446b81223d43331b534f

Comment by Githook User [ 16/Oct/15 ]

Author:

{u'username': u'amidvidy', u'name': u'Adam Midvidy', u'email': u'amidvidy@gmail.com'}

Message: CXX-646 rewrite integration test fixtures to use ConnectionString for all connections
Branch: legacy
https://github.com/mongodb/mongo-cxx-driver/commit/03a104709b9c3e4cbb9f5945a467ca90ed633d93

Comment by Adam Midvidy [ 06/Oct/15 ]

New pull request: https://github.com/mongodb/mongo-cxx-driver/pull/319

This makes the necessary improvements to our test infrastructure so we can prevent future regressions like this from happening again.

Comment by Adam Midvidy [ 05/Aug/15 ]

https://github.com/mongodb/mongo-cxx-driver/pull/304

Comment by Adam Midvidy [ 04/Aug/15 ]

Thanks for the detailed report sga. From your description, this sounds like a bug in the driver. I will work on reproducing this issue and then I will follow up on this ticket.

Generated at Wed Feb 07 21:59:51 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.