Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-78958

Setting up TLConnection concurrently with shutdown can result in leaking a ConnectionPool

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Service Arch
    • ALL
    • Service Arch Prioritized List, Service Arch 2023-09-18
    • 122

      TLConnection::setup takes a callback as argument, that is produced via ConnectionPool::SpecificPool::guardCallback. That producer-function puts a shared_ptr to the SpecificPool in the lambda-capture-list for the returned callback, which means the SpecificPool lifetime will be extended to the lifetime of the callback. Similarly, since the SpecificPool owns a shared_ptr to the parent ConnectionPool, it's lifetime will likewise be extended. 

       

      That callback is scheduled here to run after the TLConnection is set-up or a timer expires. However, if the server shuts-down before this process completes, it will cancel the timer, which results in the timer failing to ready the future that results in the callback being scheduled due to an early return here  . And nothing in the code insists that the final continuation of AsyncDBClient::connect from TLConnection::setup runs before process-shutdown, which means that the callback may never be scheduled and run. If the callback is therefore leaked, it leaks a shared_ptr to a SpecificPool, which in turn results in a ConnectionPool being leaked. 

            Assignee:
            backlog-server-servicearch [DO NOT USE] Backlog - Service Architecture
            Reporter:
            george.wangensteen@mongodb.com George Wangensteen
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: