Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-2329

Race in /Topology/invalidate_server/pooled

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.10.0
    • Affects Version/s: None
    • Component/s: libmongoc, Testing
    • None

      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

            Assignee:
            Unassigned Unassigned
            Reporter:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: