-
Type: Bug
-
Resolution: Fixed
-
Priority: Critical - P2
-
Affects Version/s: 0.0.3
-
Component/s: Connections
-
None
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.