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

Experiencing hang when try to clean up mongo connection pool

    • Type: Icon: Task Task
    • Resolution: Cannot Reproduce
    • Priority: Icon: Major - P3 Major - P3
    • TBD
    • Affects Version/s: 1.3.3
    • Component/s: libmongoc
    • None
    • Environment:
      Windows 7

      We are using smart pointers to initialize mongo connection pool. Following is code snippet:

        mongoc_init();
        mongoc_log_set_handler(mongoLogHandler, nullptr);
        mongoc_uri_t* p_uri = mongoc_uri_new(mongo_complete.c_str());
        assert(p_uri);
      
        // shared ptr with custom deleter
        auto sp_pool = shared_ptr<mongoc_client_pool_t>(
                         mongoc_client_pool_new(p_uri),
                         [](mongoc_client_pool_t * p)
        {
         * mongoc_client_pool_destroy(p);*
          mongoc_cleanup();
        }
                       );
        assert(sp_pool);
        mongoc_uri_destroy(p_uri);
      

      But application seems to hang when mongoc_client_pool_destroy(p) is called. Further debugging shows it is waiting at the following code (mongoc-topology.c):
      topology->bg_thread_state = MONGOC_TOPOLOGY_BG_SHUTTING_DOWN;

       _ topology->shutdown_requested = true;
            mongoc_cond_signal (&topology->cond_server);
           *topology->bg_thread_state = MONGOC_TOPOLOGY_BG_SHUTTING_DOWN;*
            join_thread = true;_
      

      Although if we remove the mongoc_client_pool_destroy(p) then application seems to work fine.
      Any ideas what would be the reason behind the hang?

            Assignee:
            Unassigned Unassigned
            Reporter:
            tanmoy.palit@shell.com Tanmoy Palit
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: