Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-389

Race condition when disconnecting a connection pool

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Critical - P2 Critical - P2
    • 0.0.4
    • 0.0.3
    • Connections
    • None

    Description

      If a user calls pool.Disconnect while another goroutine is closing a Connection from that pool, a series of context switches may allow a connection to enter the idle pool after the Disconnect method has cleared the connections from the idle pool. This results in a deadlock wherein a user who used a context without a deadline or timeout will wait forever since we cannot acquire all the permits from the semaphore, nor can we retrieve the connection from the idle pool.

      To solve this problem, add a RWMutex that is used in pool.Disconnect and pool.returnConnection. Since it is possible for a Connection to block forever, this RWMutex should be released before calling pool.closeConnection. The pool.Disconnect method should acquire the mutex in write more before clearing the connection pool.

      Attachments

        Activity

          People

            kris.brandow@mongodb.com Kristofer Brandow (Inactive)
            kris.brandow@mongodb.com Kristofer Brandow (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: