From b0f042c94cad34d69449706335f983c5bacbcde2 Mon Sep 17 00:00:00 2001 From: abicky Date: Sat, 5 Oct 2024 16:40:00 +0900 Subject: [PATCH] debug --- .../connection_adapters/abstract_mysql_adapter_spec.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spec/activerecord/debug_errors/ext/connection_adapters/abstract_mysql_adapter_spec.rb b/spec/activerecord/debug_errors/ext/connection_adapters/abstract_mysql_adapter_spec.rb index d76df70..e206b8e 100644 --- a/spec/activerecord/debug_errors/ext/connection_adapters/abstract_mysql_adapter_spec.rb +++ b/spec/activerecord/debug_errors/ext/connection_adapters/abstract_mysql_adapter_spec.rb @@ -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)