Skip to content

Commit 4c845dd

Browse files
committed
Debug fetch_multi leaks
1 parent 78d5bf4 commit 4c845dd

File tree

5 files changed

+54
-0
lines changed

5 files changed

+54
-0
lines changed

lib/identity_cache.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ def should_fill_cache? # :nodoc:
116116
end
117117

118118
def should_use_cache? # :nodoc:
119+
puts " ===> in identity_cache.rb should_use_cache? "
119120
ActiveRecord::Base.connection_handler.connection_pool_list(ActiveRecord::Base.current_role).none? do |pool|
120121
pool.active_connection? &&
121122
# Rails wraps each of your tests in a transaction, so that any changes

lib/identity_cache/cache_fetcher.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,33 @@ def clear
6767
def fetch_multi(keys, &block)
6868
results = cas_multi(keys, &block)
6969
results = add_multi(keys, &block) if results.nil?
70+
71+
# binding.pry
72+
73+
def do_division_by_zero; 5 / 0; end
74+
# begin
75+
# do_division_by_zero
76+
# rescue => exception
77+
# puts "catch_fetcher - caught the division_by_zero exception in fetch_multi method"
78+
# puts exception.backtrace
79+
# # raise # always reraise
80+
# end
81+
82+
keys.each do |k|
83+
puts "CacheFetcher - Found Product key: #{k}" if k.include?(":blob:Product:")
84+
85+
if k.include?(":blob:Product:")
86+
binding.pry
87+
# begin
88+
# do_division_by_zero
89+
# rescue => exception
90+
# puts "CacheFetcher - caught the Product key :blob:Product: with exceptions in fetch_multi method"
91+
# puts exception.backtrace
92+
# # raise # always reraise
93+
# end
94+
end
95+
96+
end
7097
results
7198
end
7299

lib/identity_cache/cache_key_loader.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ class << self
2828
def load(cache_fetcher, db_key, cache_fetcher_options = {})
2929
cache_key = cache_fetcher.cache_key(db_key)
3030

31+
if k.include?(":blob:Product:")
32+
binding.pry
33+
# begin
34+
# do_division_by_zero
35+
# rescue => exception
36+
# puts "CacheFetcher - caught the Product key :blob:Product: with exceptions in fetch_multi method"
37+
# puts exception.backtrace
38+
# # raise # always reraise
39+
# end
40+
end
41+
3142
db_value = nil
3243

3344
cache_value = IdentityCache.fetch(cache_key, cache_fetcher_options) do

lib/identity_cache/fallback_fetcher.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ def clear
2222

2323
def fetch_multi(keys)
2424
results = @cache_backend.read_multi(*keys)
25+
26+
# binding.pry
27+
def do_division_by_zero; 5 / 0; end
28+
begin
29+
do_division_by_zero
30+
rescue => exception
31+
puts "catch_fetcher - caught the division_by_zero exception in fetch_multi method"
32+
puts exception.backtrace
33+
# raise # always reraise
34+
end
35+
2536
missed_keys = keys - results.keys
2637
unless missed_keys.empty?
2738
replacement_results = yield missed_keys

lib/identity_cache/memoized_cache_proxy.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ def fetch_multi(*keys)
106106
result = ActiveSupport::Notifications.instrument("cache_fetch_multi.identity_cache") do |payload|
107107
payload[:resolve_miss_time] = 0.0
108108

109+
keys.each do |k|
110+
puts "MemoizedCacheProxy - Found Product key: #{k}" if k.include?(":blob:Product:")
111+
end
112+
109113
result = fetch_multi_memoized(keys) do |non_memoized_keys|
110114
memo_miss_keys = non_memoized_keys
111115
@cache_fetcher.fetch_multi(non_memoized_keys) do |missing_keys|

0 commit comments

Comments
 (0)