Skip to content

Instantly share code, notes, and snippets.

@tarcieri
Last active August 29, 2015 14:13
Show Gist options
  • Save tarcieri/303c5dcf803b0e5d021d to your computer and use it in GitHub Desktop.
Save tarcieri/303c5dcf803b0e5d021d to your computer and use it in GitHub Desktop.
Redis request interleaving repro (Ruby 2.1+)
require 'redis'
require 'timeout'
redis = Redis.new
redis.set('chunky', 'bacon')
res_a = nil
res_b = nil
count = 0
outer_count = 0
loop {
begin
Timeout.timeout(0.5) {
loop {
res_a = redis.info
puts "got res_a: #{res_a}" unless res_a.is_a? Hash
res_b = redis.get "chunky"
if !(res_b =~ /bacon/)
puts "got: res_b: #{res_b} count: #{count} outer_count: #{outer_count}"
exit!(0)
else
count += 1
p count
end
}
}
rescue
end
outer_count += 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment