Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make both threaded connection pools avoid disconnecting connections w…
…hile holding the connection pool mutex This fixes a deadlock issue in the shared_threaded connection pool when using the connection_validator or connection_expiration extensions, and fixes deadlock issues when using :connection_handling=>:disconnect Database option and either extension in both threaded connection pools. To implement this, in the sharded threaded pool, add a @connections_to_disconnect array and store the connections to disconnect in it, then check that in the hold method's ensure block. This requires an additional grab of the mutex. In the regular threaded pool, the only time where the disconnect occurs while holding the pool mutex is when using :connection_handling=>:disconnect, so just move the related code in the hold method's ensure block. In both pools, if the maximum number of connection is reached, and we are checking for dead threads, assume connections allocated to the dead threads are bad. There's no guarantee what the state of those connections is, and returning them to the pool is probably a bad choice. This also allows immediately creating a new connection in such a case, where previously that case may block until the connection pool timeout if the pool is otherwise idle.
- Loading branch information
1 parent
a984cb7
commit 0db9e00
Showing
7 changed files
with
101 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters