Connection pool improvements#301
Draft
rsamoilov wants to merge 11 commits into
Draft
Conversation
this way we don't establish extra connections under low load
this ensures we skip first `min_connections` connections and iterate starting from the end of the list, which is where preconnected connections are located
if a fiber is killed while waiting on a DB query, the `conn.active?` call inside `reap` will block until the query is finished. Which is why we now wrap it into a fiber to ensure it doesn't block the reactor. Additionally, new connections are now added to the bottom of the list to preserve active connections (created based on `min_connections`) at the top
…s at the same time this is the same approach as in `reap`: connections are removed from the pool before pinging. This ensures no other query can use the connection while it's being pinged
bdf204f to
b37ff91
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several enhancements to the ActiveRecord connection pool extension, focusing on improved connection lifecycle management, configuration flexibility, and maintenance routines. It also updates database configuration templates to use a more descriptive parameter name. The most important changes are grouped below.
retire_old_connections), proactively establish minimum connections (preconnect), and keep idle connections alive with pings (keep_alive).flushmethod to always preserve at least the minimum number of connections and only run on the owner threadreapandflushmethods to ensure maintenance is only performed by the framework, thus disabling the standard ActiveRecord reaper.