Distribute connections to previously blocked threads when we're done #27108
Conversation
# it to timeout with ConnectionTimeoutError | ||
if (group_action_method == :disconnect || group_action_method == :disconnect!) && pool.num_waiting_in_queue > 0 | ||
pool.with_connection {} # create a new connection in case there are threads still stuck in a queue | ||
end |
matthewd
Nov 19, 2016
Author
Member
This change turned out to be very easy to test 😊
This change turned out to be very easy to test
activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
Outdated
@@ -699,6 +680,8 @@ def checkout_for_exclusive_access(checkout_timeout) | |||
end | |||
|
|||
def with_new_connections_blocked | |||
num_new_conns_required = 0 |
kamipo
Nov 19, 2016
Member
num_new_conns_required
is only used in ensure block.
num_new_conns_required
is only used in ensure block.
Two methods block new connections; we were already doing the right thing for clear_reloadable_connections, but it's better placed in with_new_connections_blocked, where it can work for disconnect too.
d314646
matthewd
added a commit
that referenced
this pull request
Nov 24, 2016
…ocking Distribute connections to previously blocked threads when we're done
Backported as b79c7fe |
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.
Two methods block new connections; we were already doing the right thing for
clear_reloadable_connections
, but it's better placed inwith_new_connections_blocked
, where it can work fordisconnect
too.cc @thedarkone
Follow-up to #27057, to address a nearby-but-separate issue we spotted while looking at that.