diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 02d307d6..318e8c18 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,17 +15,19 @@ jobs: fail-fast: false max-parallel: 8 matrix: - activerecord: ["6.1", "7.0", "7.1", "head"] + activerecord: ["6.1", "7.2", "8.0", "head"] ruby: ["3.1", "3.2", "3.3", "head"] mysql: ["5.7", "8.0"] adapter: ["mysql2", "trilogy"] exclude: - activerecord: 6.1 ruby: head - - activerecord: 7.0 + - activerecord: 7.2 ruby: head + - activerecord: 8.0 + ruby: 3.1 - activerecord: head - ruby: 3.0 + ruby: 3.1 env: BUNDLE_GEMFILE: "${{ github.workspace }}/gemfiles/activerecord_${{ matrix.activerecord }}.gemfile" diff --git a/Appraisals b/Appraisals index 567976bd..871ce2f8 100644 --- a/Appraisals +++ b/Appraisals @@ -3,13 +3,12 @@ appraise "activerecord-6.1" do gem "activerecord-trilogy-adapter" end -appraise "activerecord-7.0" do - gem "activerecord", "7.0.8" - gem "activerecord-trilogy-adapter" +appraise "activerecord-7.2" do + gem "activerecord", "7.2.2.1" end -appraise "activerecord-7.1" do - gem "activerecord", "7.1.1" +appraise "activerecord-8.0" do + gem "activerecord", "8.0.1" end appraise "activerecord-head" do diff --git a/Gemfile.lock b/Gemfile.lock index df77eda3..68b81d6e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,14 +7,15 @@ PATH GEM remote: https://rubygems.org/ specs: - activemodel (7.2.0) - activesupport (= 7.2.0) - activerecord (7.2.0) - activemodel (= 7.2.0) - activesupport (= 7.2.0) + activemodel (8.0.1) + activesupport (= 8.0.1) + activerecord (8.0.1) + activemodel (= 8.0.1) + activesupport (= 8.0.1) timeout (>= 0.4.0) - activesupport (7.2.0) + activesupport (8.0.1) base64 + benchmark (>= 0.3) bigdecimal concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) @@ -24,45 +25,50 @@ GEM minitest (>= 5.1) securerandom (>= 0.3) tzinfo (~> 2.0, >= 2.0.5) + uri (>= 0.13.1) after_do (0.4.0) appraisal (2.5.0) bundler rake thor (>= 0.14.0) base64 (0.2.0) - bigdecimal (3.1.8) + benchmark (0.4.0) + bigdecimal (3.1.9) byebug (11.1.3) - concurrent-ruby (1.3.4) - connection_pool (2.4.1) + concurrent-ruby (1.3.5) + connection_pool (2.5.0) docile (1.4.1) drb (2.2.1) - i18n (1.14.5) + i18n (1.14.7) concurrent-ruby (~> 1.0) - logger (1.6.0) - minitest (5.25.1) + logger (1.6.5) + minitest (5.25.4) mocha (2.4.5) ruby2_keywords (>= 0.0.5) mysql2 (0.5.6) + ostruct (0.6.1) rake (13.2.1) retriable (3.1.2) ruby2_keywords (0.0.5) - securerandom (0.3.1) + securerandom (0.4.1) simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) - thor (1.3.1) - timeout (0.4.1) + thor (1.3.2) + timeout (0.4.3) toxiproxy (2.0.2) trilogy (2.8.1) tzinfo (2.0.6) concurrent-ruby (~> 1.0) + uri (1.0.2) PLATFORMS arm64-darwin-21 arm64-darwin-22 + arm64-darwin-23 x86_64-darwin-20 x86_64-linux @@ -72,13 +78,15 @@ DEPENDENCIES appraisal byebug lhm-shopify! + logger minitest mocha mysql2 + ostruct rake simplecov toxiproxy trilogy BUNDLED WITH - 2.2.22 + 2.6.3 diff --git a/gemfiles/activerecord_6.1.gemfile.lock b/gemfiles/activerecord_6.1.gemfile.lock index df962213..14f230f3 100644 --- a/gemfiles/activerecord_6.1.gemfile.lock +++ b/gemfiles/activerecord_6.1.gemfile.lock @@ -31,10 +31,12 @@ GEM docile (1.4.0) i18n (1.14.1) concurrent-ruby (~> 1.0) + logger (1.6.1) minitest (5.22.2) mocha (2.1.0) ruby2_keywords (>= 0.0.5) mysql2 (0.5.5) + ostruct (0.6.1) rake (13.0.6) retriable (3.1.2) ruby2_keywords (0.0.5) @@ -44,7 +46,7 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) - thor (1.2.2) + thor (1.3.2) toxiproxy (2.0.2) trilogy (2.6.0) tzinfo (2.0.6) @@ -64,9 +66,11 @@ DEPENDENCIES appraisal byebug lhm-shopify! + logger minitest mocha mysql2 + ostruct rake simplecov toxiproxy diff --git a/gemfiles/activerecord_7.0.gemfile b/gemfiles/activerecord_7.2.gemfile similarity index 59% rename from gemfiles/activerecord_7.0.gemfile rename to gemfiles/activerecord_7.2.gemfile index b5dc01e4..667f6581 100644 --- a/gemfiles/activerecord_7.0.gemfile +++ b/gemfiles/activerecord_7.2.gemfile @@ -2,7 +2,6 @@ source "https://rubygems.org" -gem "activerecord", "7.0.8" -gem "activerecord-trilogy-adapter" +gem "activerecord", "7.2.2.1" gemspec path: "../" diff --git a/gemfiles/activerecord_7.0.gemfile.lock b/gemfiles/activerecord_7.2.gemfile.lock similarity index 54% rename from gemfiles/activerecord_7.0.gemfile.lock rename to gemfiles/activerecord_7.2.gemfile.lock index 892f73d9..7c8b650a 100644 --- a/gemfiles/activerecord_7.0.gemfile.lock +++ b/gemfiles/activerecord_7.2.gemfile.lock @@ -7,68 +7,84 @@ PATH GEM remote: https://rubygems.org/ specs: - activemodel (7.0.8) - activesupport (= 7.0.8) - activerecord (7.0.8) - activemodel (= 7.0.8) - activesupport (= 7.0.8) - activerecord-trilogy-adapter (3.1.2) - activerecord (>= 6.0.a, < 7.1.a) - trilogy (>= 2.4.0) - activesupport (7.0.8) - concurrent-ruby (~> 1.0, >= 1.0.2) + activemodel (7.2.2.1) + activesupport (= 7.2.2.1) + activerecord (7.2.2.1) + activemodel (= 7.2.2.1) + activesupport (= 7.2.2.1) + timeout (>= 0.4.0) + activesupport (7.2.2.1) + base64 + benchmark (>= 0.3) + bigdecimal + concurrent-ruby (~> 1.0, >= 1.3.1) + connection_pool (>= 2.2.5) + drb i18n (>= 1.6, < 2) + logger (>= 1.4.2) minitest (>= 5.1) - tzinfo (~> 2.0) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) after_do (0.4.0) appraisal (2.5.0) bundler rake thor (>= 0.14.0) + base64 (0.2.0) + benchmark (0.4.0) + bigdecimal (3.1.9) byebug (11.1.3) - concurrent-ruby (1.2.2) + concurrent-ruby (1.3.5) + connection_pool (2.5.0) docile (1.4.0) - i18n (1.14.1) + drb (2.2.1) + i18n (1.14.7) concurrent-ruby (~> 1.0) - minitest (5.22.2) + logger (1.6.5) + minitest (5.25.4) mocha (2.1.0) ruby2_keywords (>= 0.0.5) mysql2 (0.5.5) + ostruct (0.6.1) rake (13.0.6) retriable (3.1.2) ruby2_keywords (0.0.5) + securerandom (0.4.1) simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) - thor (1.2.2) + thor (1.3.2) + timeout (0.4.3) toxiproxy (2.0.2) - trilogy (2.6.0) + trilogy (2.9.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) PLATFORMS arm64-darwin-21 arm64-darwin-22 + arm64-darwin-23 x86_64-darwin-20 x86_64-linux DEPENDENCIES - activerecord (= 7.0.8) - activerecord-trilogy-adapter + activerecord (= 7.2.2.1) after_do appraisal byebug lhm-shopify! + logger minitest mocha mysql2 + ostruct rake simplecov toxiproxy trilogy BUNDLED WITH - 2.2.22 + 2.6.3 diff --git a/gemfiles/activerecord_7.1.gemfile b/gemfiles/activerecord_8.0.gemfile similarity index 76% rename from gemfiles/activerecord_7.1.gemfile rename to gemfiles/activerecord_8.0.gemfile index c869c2eb..5b1115f7 100644 --- a/gemfiles/activerecord_7.1.gemfile +++ b/gemfiles/activerecord_8.0.gemfile @@ -2,6 +2,6 @@ source "https://rubygems.org" -gem "activerecord", "7.1.1" +gem "activerecord", "8.0.1" gemspec path: "../" diff --git a/gemfiles/activerecord_7.1.gemfile.lock b/gemfiles/activerecord_8.0.gemfile.lock similarity index 61% rename from gemfiles/activerecord_7.1.gemfile.lock rename to gemfiles/activerecord_8.0.gemfile.lock index bf664194..283aca32 100644 --- a/gemfiles/activerecord_7.1.gemfile.lock +++ b/gemfiles/activerecord_8.0.gemfile.lock @@ -7,77 +7,86 @@ PATH GEM remote: https://rubygems.org/ specs: - activemodel (7.1.1) - activesupport (= 7.1.1) - activerecord (7.1.1) - activemodel (= 7.1.1) - activesupport (= 7.1.1) + activemodel (8.0.1) + activesupport (= 8.0.1) + activerecord (8.0.1) + activemodel (= 8.0.1) + activesupport (= 8.0.1) timeout (>= 0.4.0) - activesupport (7.1.1) + activesupport (8.0.1) base64 + benchmark (>= 0.3) bigdecimal - concurrent-ruby (~> 1.0, >= 1.0.2) + concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) + logger (>= 1.4.2) minitest (>= 5.1) - mutex_m - tzinfo (~> 2.0) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) + uri (>= 0.13.1) after_do (0.4.0) appraisal (2.5.0) bundler rake thor (>= 0.14.0) - base64 (0.1.1) - bigdecimal (3.1.4) + base64 (0.2.0) + benchmark (0.4.0) + bigdecimal (3.1.9) byebug (11.1.3) - concurrent-ruby (1.2.2) - connection_pool (2.4.1) + concurrent-ruby (1.3.5) + connection_pool (2.5.0) docile (1.4.0) - drb (2.1.1) - ruby2_keywords + drb (2.2.1) i18n (1.14.1) concurrent-ruby (~> 1.0) + logger (1.6.1) minitest (5.22.2) mocha (2.1.0) ruby2_keywords (>= 0.0.5) - mutex_m (0.1.2) mysql2 (0.5.5) + ostruct (0.6.1) rake (13.0.6) retriable (3.1.2) ruby2_keywords (0.0.5) + securerandom (0.4.1) simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) - thor (1.2.2) - timeout (0.4.0) + thor (1.3.2) + timeout (0.4.3) toxiproxy (2.0.2) - trilogy (2.6.0) + trilogy (2.9.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) + uri (1.0.2) PLATFORMS arm64-darwin-21 arm64-darwin-22 + arm64-darwin-23 x86_64-darwin-20 x86_64-linux DEPENDENCIES - activerecord (= 7.1.1) + activerecord (= 8.0.1) after_do appraisal byebug lhm-shopify! + logger minitest mocha mysql2 + ostruct rake simplecov toxiproxy trilogy BUNDLED WITH - 2.2.22 + 2.6.3 diff --git a/gemfiles/activerecord_head.gemfile.lock b/gemfiles/activerecord_head.gemfile.lock index d39dba44..bad4c1a7 100644 --- a/gemfiles/activerecord_head.gemfile.lock +++ b/gemfiles/activerecord_head.gemfile.lock @@ -1,16 +1,17 @@ GIT remote: https://github.com/rails/rails.git - revision: f4a9b7618fc32f0d3b2c0ff03a3f34f4964cc553 + revision: bdad2707835949a96dd29e747b8c324593efd4d8 branch: main specs: - activemodel (8.0.0.alpha) - activesupport (= 8.0.0.alpha) - activerecord (8.0.0.alpha) - activemodel (= 8.0.0.alpha) - activesupport (= 8.0.0.alpha) + activemodel (8.1.0.alpha) + activesupport (= 8.1.0.alpha) + activerecord (8.1.0.alpha) + activemodel (= 8.1.0.alpha) + activesupport (= 8.1.0.alpha) timeout (>= 0.4.0) - activesupport (8.0.0.alpha) + activesupport (8.1.0.alpha) base64 + benchmark (>= 0.3) bigdecimal concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) @@ -20,6 +21,7 @@ GIT minitest (>= 5.1) securerandom (>= 0.3) tzinfo (~> 2.0, >= 2.0.5) + uri (>= 0.13.1) PATH remote: .. @@ -36,38 +38,42 @@ GEM rake thor (>= 0.14.0) base64 (0.2.0) - bigdecimal (3.1.8) + benchmark (0.4.0) + bigdecimal (3.1.9) byebug (11.1.3) - concurrent-ruby (1.3.3) - connection_pool (2.4.1) + concurrent-ruby (1.3.5) + connection_pool (2.5.0) docile (1.4.1) drb (2.2.1) - i18n (1.14.5) + i18n (1.14.7) concurrent-ruby (~> 1.0) - logger (1.6.0) - minitest (5.24.1) + logger (1.6.5) + minitest (5.25.4) mocha (2.4.5) ruby2_keywords (>= 0.0.5) mysql2 (0.5.6) + ostruct (0.6.1) rake (13.2.1) retriable (3.1.2) ruby2_keywords (0.0.5) - securerandom (0.3.1) + securerandom (0.4.1) simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) - thor (1.3.1) - timeout (0.4.1) + thor (1.3.2) + timeout (0.4.3) toxiproxy (2.0.2) - trilogy (2.8.1) + trilogy (2.9.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) + uri (1.0.2) PLATFORMS arm64-darwin-22 + arm64-darwin-23 x86_64-linux DEPENDENCIES @@ -76,13 +82,15 @@ DEPENDENCIES appraisal byebug lhm-shopify! + logger minitest mocha mysql2 + ostruct rake simplecov toxiproxy trilogy BUNDLED WITH - 2.2.22 + 2.6.3 diff --git a/lhm.gemspec b/lhm.gemspec index 9d074674..559e3022 100644 --- a/lhm.gemspec +++ b/lhm.gemspec @@ -36,4 +36,6 @@ Gem::Specification.new do |s| s.add_development_dependency 'toxiproxy' s.add_development_dependency 'appraisal' s.add_development_dependency 'byebug' + s.add_development_dependency 'ostruct' + s.add_development_dependency 'logger' end diff --git a/lib/lhm/sql_retry.rb b/lib/lhm/sql_retry.rb index b27f0cbc..152edc2b 100644 --- a/lib/lhm/sql_retry.rb +++ b/lib/lhm/sql_retry.rb @@ -199,6 +199,7 @@ def retriable_trilogy_errors /The MySQL server is running with the --read-only option so it cannot execute this statement/, ], Trilogy::ConnectionError => nil, + Trilogy::TimeoutError => nil, } if ActiveRecord::VERSION::STRING >= "7.1" diff --git a/spec/integration/lhm_spec.rb b/spec/integration/lhm_spec.rb index 85814605..53037eae 100644 --- a/spec/integration/lhm_spec.rb +++ b/spec/integration/lhm_spec.rb @@ -616,7 +616,13 @@ table_create(:users) 100.times { |n| execute("insert into users set reference = '#{ n }'") } - assert_raises ActiveRecord::StatementInvalid do + error = if ActiveRecord.version >= ::Gem::Version.new('8.1.0.alpha') + ActiveRecord::ConnectionNotEstablished + else + ActiveRecord::StatementInvalid + end + + assert_raises error do Toxiproxy[:mysql_master].down do Lhm.change_table(:users, :atomic_switch => false) do |t| t.ddl("ALTER TABLE #{t.name} CHANGE id id bigint (20) NOT NULL") diff --git a/spec/integration/sql_retry/db_connection_helper.rb b/spec/integration/sql_retry/db_connection_helper.rb index 933e75ac..ef110595 100644 --- a/spec/integration/sql_retry/db_connection_helper.rb +++ b/spec/integration/sql_retry/db_connection_helper.rb @@ -20,7 +20,7 @@ def new_mysql_connection(role = :master, with_data = false, toxic = false) :database => test_db_name, :port => db_config[key]['port'] ) - conn = conn.connection + conn = conn.respond_to?(:lease_connection) ? conn.lease_connection : conn.connection init_with_dummy_data(conn) if with_data conn end diff --git a/spec/integration/sql_retry/lock_wait_spec.rb b/spec/integration/sql_retry/lock_wait_spec.rb index 9ceb2abd..a35b58e7 100644 --- a/spec/integration/sql_retry/lock_wait_spec.rb +++ b/spec/integration/sql_retry/lock_wait_spec.rb @@ -81,10 +81,12 @@ logs = @logger.string.split("\n") assert_equal 2, logs.length - assert logs.first.include?("Lock wait timeout exceeded; try restarting transaction' - 1 tries") + assert logs.first.include?("Lock wait timeout exceeded; try restarting transaction") + assert logs.first.include?("- 1 tries") assert logs.first.include?("0.2 seconds until the next try") - assert logs.last.include?("Lock wait timeout exceeded; try restarting transaction' - 2 tries") + assert logs.last.include?("Lock wait timeout exceeded; try restarting transaction") + assert logs.last.include?("- 2 tries") assert logs.last.include?("0.2 seconds until the next try") end