Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
abicky committed Oct 5, 2024
1 parent b0e6176 commit b0f042c
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,23 @@ def cause_deadlock(role:)
context "when ActiveRecord::LockWaitTimeout occurs" do
it "displays transactions and processlist" do
barrier = CyclicBarrier.new(2)

logger = Logger.new($stderr)
ths = Array.new(2) do
Thread.new do
User.transaction do
barrier.await(1)
logger.info("#{Thread.current.object_id}: #{User.connection.execute("show variables like 'innodb_lock_wait_timeout'").to_a.first.join('=')}")
logger.info("#{Thread.current.object_id}: User.lock.find_by!")
User.lock.find_by!(name: 'foo')
sleep 2
logger.info("#{Thread.current.object_id}: done")
end
end
end

ths.each.with_index do |th, i|
logger.info("ths[#{i}].object_id = #{th.object_id}")
end
expect {
ths.each(&:join)
}.to raise_error(ActiveRecord::LockWaitTimeout)
Expand Down

0 comments on commit b0f042c

Please sign in to comment.