Distribute connections to previously blocked threads when we're done #27108

Merged
merged 1 commit into from Nov 24, 2016

Projects

None yet

2 participants

@matthewd
Member

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.

cc @thedarkone

Follow-up to #27057, to address a nearby-but-separate issue we spotted while looking at that.

@matthewd matthewd self-assigned this Nov 19, 2016
- # 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
matthewd Nov 19, 2016 Member

This change turned out to be very easy to test 😊

@@ -699,6 +680,8 @@ def checkout_for_exclusive_access(checkout_timeout)
end
def with_new_connections_blocked
+ num_new_conns_required = 0
@kamipo
kamipo Nov 19, 2016 Member

num_new_conns_required is only used in ensure block.

@matthewd matthewd Distribute connections to previously blocked threads when we're done
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 matthewd merged commit 3b13761 into rails:master Nov 24, 2016

1 of 2 checks passed

codeclimate Code Climate is analyzing this code.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@matthewd
Member

Backported as b79c7fe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment