diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 473508f..273fe6d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,13 +17,19 @@ jobs: - '2.7' - '3.0' - '3.1' + - '3.2' + - '3.3' activerecord-version: - - '6' - - '7' + - '6_0' + - '6_1' + - '7_0' + - '7_1' exclude: - - # activerecord-7 doesn't support Ruby 2.6 - ruby-version: '2.6' - activerecord-version: '7' + # activerecord-7 doesn't support Ruby 2.6 + - ruby-version: '2.6' + activerecord-version: '7_0' + - ruby-version: '2.6' + activerecord-version: '7_1' services: mysql: diff --git a/gemfiles/activerecord_6.gemfile b/gemfiles/activerecord_6.gemfile deleted file mode 100644 index dcd6b25..0000000 --- a/gemfiles/activerecord_6.gemfile +++ /dev/null @@ -1,2 +0,0 @@ -eval_gemfile("../Gemfile") -gem "activerecord", "~> 6.0" diff --git a/gemfiles/activerecord_6_0.gemfile b/gemfiles/activerecord_6_0.gemfile new file mode 100644 index 0000000..ee55b54 --- /dev/null +++ b/gemfiles/activerecord_6_0.gemfile @@ -0,0 +1,2 @@ +eval_gemfile("../Gemfile") +gem "activerecord", "~> 6.0.0" diff --git a/gemfiles/activerecord_6_1.gemfile b/gemfiles/activerecord_6_1.gemfile new file mode 100644 index 0000000..44404eb --- /dev/null +++ b/gemfiles/activerecord_6_1.gemfile @@ -0,0 +1,2 @@ +eval_gemfile("../Gemfile") +gem "activerecord", "~> 6.1.0" diff --git a/gemfiles/activerecord_7.gemfile b/gemfiles/activerecord_7.gemfile deleted file mode 100644 index 830ef3f..0000000 --- a/gemfiles/activerecord_7.gemfile +++ /dev/null @@ -1,2 +0,0 @@ -eval_gemfile("../Gemfile") -gem "activerecord", "~> 7.0" diff --git a/gemfiles/activerecord_7_0.gemfile b/gemfiles/activerecord_7_0.gemfile new file mode 100644 index 0000000..4a24b63 --- /dev/null +++ b/gemfiles/activerecord_7_0.gemfile @@ -0,0 +1,2 @@ +eval_gemfile("../Gemfile") +gem "activerecord", "~> 7.0.0" diff --git a/gemfiles/activerecord_7_1.gemfile b/gemfiles/activerecord_7_1.gemfile new file mode 100644 index 0000000..afdf59b --- /dev/null +++ b/gemfiles/activerecord_7_1.gemfile @@ -0,0 +1,2 @@ +eval_gemfile("../Gemfile") +gem "activerecord", "~> 7.1.0" diff --git a/lib/activerecord/debug_errors/ext/connection_adapters/abstract_mysql_adapter.rb b/lib/activerecord/debug_errors/ext/connection_adapters/abstract_mysql_adapter.rb index 77f3f25..c1f5bfc 100644 --- a/lib/activerecord/debug_errors/ext/connection_adapters/abstract_mysql_adapter.rb +++ b/lib/activerecord/debug_errors/ext/connection_adapters/abstract_mysql_adapter.rb @@ -80,6 +80,13 @@ def display_innodb_status_section(section_name) end end +ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter.descendants.each do |adapter| + adapter.prepend(ActiveRecord::DebugErrors::DisplayMySQLInformation) +end + class ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter - prepend ActiveRecord::DebugErrors::DisplayMySQLInformation + def self.inherited(base) + super + base.prepend(ActiveRecord::DebugErrors::DisplayMySQLInformation) + end end diff --git a/spec/activerecord/debug_errors/ext/connection_adapters/connection_pool_spec.rb b/spec/activerecord/debug_errors/ext/connection_adapters/connection_pool_spec.rb index 7a86bc7..97e3803 100644 --- a/spec/activerecord/debug_errors/ext/connection_adapters/connection_pool_spec.rb +++ b/spec/activerecord/debug_errors/ext/connection_adapters/connection_pool_spec.rb @@ -20,11 +20,20 @@ it "displays connection owners and other threads" do Thread.new { sleep 10 } # another thread + mutex = Mutex.new + cv = ConditionVariable.new + expect { ActiveRecord::Base.connection # Ensure to acquire a connection Array.new(ActiveRecord::Base.connection_pool.size) do Thread.new do - ActiveRecord::Base.connection_pool.checkout(0.1) + mutex.synchronize do + ActiveRecord::Base.connection_pool.checkout(0.1) + cv.wait(mutex, 1) + rescue + cv.broadcast + raise + end end end.each(&:join) }.to raise_error(ActiveRecord::ConnectionTimeoutError) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4ec8eef..6414d2e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -26,7 +26,11 @@ } user_for_replica = 'activerecord-debug_errors' - ActiveRecord::Base.legacy_connection_handling = false + # For compatibility. Rails deprecated since 6.1 and removed this option since 7.1. + # https://github.com/rails/rails/pull/44827/commits/ad52c0a19714a1b87a7d0c626a8b364cf95414cf + if ActiveRecord::Base.respond_to?(:legacy_connection_handling) + ActiveRecord::Base.legacy_connection_handling = false + end ActiveRecord::Base.configurations = { default_env: { primary: base_db_config,