File tree Expand file tree Collapse file tree 1 file changed +6
-14
lines changed
lib/activerecord-refresh_connection/active_record/connection_adapters Expand file tree Collapse file tree 1 file changed +6
-14
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ def clear_connections
3737 if legacy_connection_handling?
3838 clear_legacy_compatible_connections
3939 else
40- clear_all_roles_connections
40+ clear_multi_db_connections
4141 end
4242 elsif @ar_version >= AR_VERSION_6_0
4343 clear_legacy_compatible_connections
@@ -54,22 +54,14 @@ def legacy_connection_handling?
5454 end
5555 end
5656
57- def all_roles
58- roles = [ ]
59- ActiveRecord ::Base . connection_handler . instance_variable_get ( :@owner_to_pool_manager ) . each_value do |pool_manager |
60- roles . concat ( pool_manager . role_names )
61- end
62- roles . uniq
63- end
64-
65- def clear_all_roles_connections
57+ def clear_multi_db_connections
6658 if should_clear_all_connections?
67- all_roles . each do |role |
68- ActiveRecord :: Base . clear_all_connections! ( role )
59+ ActiveRecord :: Base . connection_handler . all_connection_pools . each do |pool |
60+ pool . disconnect!
6961 end
7062 else
71- all_roles . each do |role |
72- ActiveRecord :: Base . clear_active_connections! ( role )
63+ ActiveRecord :: Base . connection_handler . all_connection_pools . each do |pool |
64+ pool . release_connection if pool . active_connection? && ! pool . connection . transaction_open?
7365 end
7466 end
7567 end
You can’t perform that action at this time.
0 commit comments