Skip to content

Commit c222568

Browse files
committed
Revert "Merge pull request rails#41192 from kamipo/dont_return_pools"
This reverts commit 9d8ff32, reversing changes made to 9cde02e. Need to revert this so I can revert another PR.
1 parent c38db72 commit c222568

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

activerecord/lib/active_record/query_cache.rb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,30 @@ def uncached(&block)
2626
end
2727

2828
def self.run
29+
pools = []
30+
2931
if ActiveRecord::Base.legacy_connection_handling
30-
ActiveRecord::Base.connection_handlers.each_value do |handler|
31-
handler.connection_pool_list.each(&:enable_query_cache!)
32+
ActiveRecord::Base.connection_handlers.each do |key, handler|
33+
pools.concat(handler.connection_pool_list.each { |p| p.enable_query_cache! })
3234
end
3335
else
34-
ActiveRecord::Base.connection_handler.all_connection_pools.each(&:enable_query_cache!)
36+
pools.concat(ActiveRecord::Base.connection_handler.all_connection_pools.each { |p| p.enable_query_cache! })
3537
end
38+
39+
pools
3640
end
3741

38-
def self.complete(_)
42+
def self.complete(pools)
43+
pools.each { |pool| pool.disable_query_cache! }
44+
3945
if ActiveRecord::Base.legacy_connection_handling
40-
ActiveRecord::Base.connection_handlers.each_value do |handler|
46+
ActiveRecord::Base.connection_handlers.each do |_, handler|
4147
handler.connection_pool_list.each do |pool|
42-
pool.disable_query_cache!
4348
pool.release_connection if pool.active_connection? && !pool.connection.transaction_open?
4449
end
4550
end
4651
else
4752
ActiveRecord::Base.connection_handler.all_connection_pools.each do |pool|
48-
pool.disable_query_cache!
4953
pool.release_connection if pool.active_connection? && !pool.connection.transaction_open?
5054
end
5155
end

0 commit comments

Comments
 (0)