-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add :min_wait_timeout option to sharded_threaded connection pool and …
…default to 0.1, fixes stalling observed on JRuby The sharded_threaded connection pool is implemented via per-shard mutexes, condition variables, and arrays to store the connections. If there is not an available connection and the pool is at maximum, Sequel will wait until a connection is available. However, if between when checking for the available connection and when waiting, a connection is checked in, it's possible for the wait to timeout even though a connection is then available. Mitigate the loss of such a race by setting a minimum wait time for the condition variable, by default, 0.1. There is no problem if there is still no connection available, since Sequel was already setup to loop in that case. This commit basically gives up some potential throughput for better behavior in the worst case. Simplify acquire while here. The true solution to this problem is to use a queue that supports a timeout when popping, which Sequel already implements in the sharded_timed_queue connection pool, but that requires at least Ruby 3.2 (Sequel will use it by default on Ruby 3.4+).
- Loading branch information
1 parent
73fed97
commit 72f08cd
Showing
3 changed files
with
23 additions
and
12 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