[CDRIVER-2329] Race in /Topology/invalidate_server/pooled Created: 15/Oct/17  Updated: 28/Oct/23  Resolved: 21/Nov/17

Status: Closed
Project: C Driver
Component/s: libmongoc, tests
Affects Version/s: None
Fix Version/s: 1.10.0

Type: Bug Priority: Minor - P4
Reporter: A. Jesse Jiryu Davis Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to CDRIVER-2394 /Topology/invalidate_server/ tests ar... Closed
is related to CDRIVER-1139 Network err must invalidate server de... Closed

 Description   

The pooled version of the test for CDRIVER-1139 can fail at the end of these lines:

   /* insert a 'fake' server description and ensure that it is invalidated by
    * driver */
   host_list_init (&fake_host_list, AF_INET, "fakeaddress", 27033);
   mongoc_server_description_init (
      fake_sd, fake_host_list.host_and_port, fake_id);
 
   fake_sd->type = MONGOC_SERVER_STANDALONE;
   mongoc_set_add (td->servers, fake_id, fake_sd);
   mongoc_topology_scanner_add (
      client->topology->scanner, &fake_host_list, fake_id);
   BSON_ASSERT (!mongoc_cluster_stream_for_server (
      &client->cluster, fake_id, true, &error));
   sd = (mongoc_server_description_t *) mongoc_set_get (td->servers, fake_id);
   BSON_ASSERT (sd);

There's a race between the test and the background scanner. If the scanner is triggered between mongoc_cluster_stream_for_server and mongoc_set_get, the server description is removed and mongoc_set_get returns NULL. If the description is destroyed then I suppose there could be a crash, but I've only observed the NULL return:

https://evergreen.mongodb.com/task/mongo_c_driver_clang37_test_latest_replica_set_noauth_sasl_nossl_patch_0a584f637249ce8e29e27d84bf7c5dcb3c9e3e89_59e3716b2a60ed5647001b37_17_10_15_14_32_12/0



 Comments   
Comment by Githook User [ 21/Nov/17 ]

Author:

{'name': 'A. Jesse Jiryu Davis', 'username': 'ajdavis', 'email': 'jesse@mongodb.com'}

Message: CDRIVER-2329 fix topology test for SSL
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/77de2c9084dcb7c2578a7e6c684da71c6bd0aeab

Comment by Githook User [ 20/Nov/17 ]

Author:

{'name': 'A. Jesse Jiryu Davis', 'username': 'ajdavis', 'email': 'jesse@mongodb.com'}

Message: CDRIVER-2329 race in topology test
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/a3558febcf6de59842c483ac660700e2efb09f52

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