[CDRIVER-4145] Do not start background monitoring when topology is invalid Created: 01/Sep/21  Updated: 28/Oct/23  Resolved: 29/Sep/21

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 1.19.1

Type: Bug Priority: Major - P3
Reporter: Kevin Albertson Assignee: Kevin Albertson
Resolution: Fixed Votes: 0
Labels: failing-on-waterfall
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Related
related to CDRIVER-4184 Assert in invalid topology in load ba... Closed

 Description   

Summary
A mongoc_client_pool_t created with a mongoc_uri_t containing loadBalanced=true and an invalid URI option results in an assertion upon first use.

To reproduce
The loadBalanced-replicaSet-errors specification test currently fails due to this bug.

To run it locally, start a local sharded cluster with TLS configured and two mongos processes on 27017 and 27018.

Run the test with:

$ export SINGLE_MONGOS_LB_URI="mongodb://localhost:27017"
$ export MULTI_MONGOS_LB_URI="mongodb://localhost:27017,localhost:27018"
$ export MONGOC_TEST_LOADBALANCED=ON
$ export MONGOC_TEST_SSL=ON
$ export MONGOC_TEST_SSL_CA_FILE=~/code/mongo-c-driver/src/libmongoc/tests/x509gen/ca.pem
$ export MONGOC_TEST_DNS_LOADBALANCED=ON
$ ./cmake-build/src/libmongoc/test-libmongoc -l "/initial_dns_seedlist_discovery/load-balanced/loadBalanced-replicaSet-errors"
...
Begin /initial_dns_seedlist_discovery/load-balanced/loadBalanced-replicaSet-errors, seed 3463113918
../src/libmongoc/src/mongoc/mongoc-topology-description-apm.c:130 _mongoc_topology_description_monitor_opening(): precondition failed: td->servers->items_len == 1



 Comments   
Comment by Kevin Albertson [ 12/Oct/21 ]

Thank you for catching. Setting the mongoc_apm_set_topology_closed_cb callback and rerunning the loadBalanced-replicaSet-errors test hit the same assertion. CDRIVER-4184 tracks the fix to that assertion.

Comment by Kaitlin Mahar [ 11/Oct/21 ]

kevin.albertson, I've vendored this fix into the Swift driver and now see a crash coming from a different spot in the C driver when running this test against Swift: https://github.com/mongodb/mongo-c-driver/blob/b2e1ae0552e1853e981fd488e8ad5039292500ef/src/libmongoc/src/mongoc/mongoc-topology-description-apm.c#L183

Comment by Githook User [ 29/Sep/21 ]

Author:

{'name': 'Kevin Albertson', 'email': 'kevin.albertson@mongodb.com', 'username': 'kevinAlbs'}

Message: CDRIVER-4145 do not monitor an invalid topology (#878)
Branch: r1.19
https://github.com/mongodb/mongo-c-driver/commit/2f05513eba3b50c194a1bd38f2bd07e5aaae8584

Comment by Githook User [ 29/Sep/21 ]

Author:

{'name': 'Kevin Albertson', 'email': 'kevin.albertson@mongodb.com', 'username': 'kevinAlbs'}

Message: CDRIVER-4145 do not monitor an invalid topology (#878)
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/a4c8c66f3638e59a6acc6733dc8e36b71062fcca

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