From 4a245573b1dd6d243c5917b39fad117e3b26b0f7 Mon Sep 17 00:00:00 2001 From: Leszek Zalewski Date: Wed, 18 Nov 2026 15:09:19 +0100 Subject: [PATCH 1/8] Update deps --- Gemfile.lock | 71 ++++++++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 6e8cd32b..cfc27faf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,20 +7,20 @@ PATH GEM remote: https://rubygems.org/ specs: - activemodel (8.0.1) - activesupport (= 8.0.1) - activerecord (8.0.1) - activemodel (= 8.0.1) - activesupport (= 8.0.1) + activemodel (8.1.4.1) + activesupport (= 8.1.4.1) + activerecord (8.1.4.1) + activemodel (= 8.1.4.1) + activesupport (= 8.1.4.1) timeout (>= 0.4.0) - activesupport (8.0.1) + activesupport (8.1.4.1) base64 - benchmark (>= 0.3) bigdecimal concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) + json logger (>= 1.4.2) minitest (>= 5.1) securerandom (>= 0.3) @@ -31,39 +31,44 @@ GEM 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.3.5) - connection_pool (2.5.0) - docile (1.4.1) - drb (2.2.1) - i18n (1.14.7) + base64 (0.3.0) + bigdecimal (4.1.3) + byebug (13.0.0) + reline (>= 0.6.0) + concurrent-ruby (1.3.8) + connection_pool (3.0.3) + drb (2.2.3) + i18n (1.15.2) concurrent-ruby (~> 1.0) - logger (1.6.5) - minitest (5.25.4) - mocha (2.4.5) + io-console (0.9.5) + json (3.1.0) + logger (1.7.0) + minitest (6.1.0) + drb (~> 2.0) + prism (>= 1.5, < 3) + mocha (3.1.0) ruby2_keywords (>= 0.0.5) - mysql2 (0.5.6) - ostruct (0.6.1) - rake (13.2.1) - retriable (3.1.2) + mysql2 (0.5.7) + bigdecimal + ostruct (0.6.3) + prism (2.1.0-arm64-darwin) + prism (2.1.0-x86_64-darwin) + prism (2.1.0-x86_64-linux-gnu) + rake (13.4.2) + reline (0.7.0) + io-console (~> 0.5) + retriable (5.0.1) 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.3.2) - timeout (0.4.3) + simplecov (1.3.2) + thor (1.5.0) + timeout (0.6.1) toxiproxy (2.0.2) - trilogy (2.8.1) + trilogy (2.13.3) + bigdecimal tzinfo (2.0.6) concurrent-ruby (~> 1.0) - uri (1.0.2) + uri (1.1.2) PLATFORMS arm64-darwin-21 From aea2b00c3b7a623892113e5cefd7370b893db459 Mon Sep 17 00:00:00 2001 From: Leszek Zalewski Date: Wed, 18 Nov 2026 15:17:58 +0100 Subject: [PATCH 2/8] Extend ruby support --- .github/workflows/test.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 09977bc4..ba158efa 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,8 +15,8 @@ jobs: fail-fast: false max-parallel: 8 matrix: - activerecord: ["7.2", "8.0", "head"] - ruby: ["3.1", "3.2", "3.3", "head"] + activerecord: ["7.2", "8.0", "8.1", "head"] + ruby: ["3.1", "3.2", "3.3", "3.4", "4.0", "head"] mysql: ["5.7", "8.0"] adapter: ["mysql2", "trilogy"] exclude: @@ -26,6 +26,8 @@ jobs: ruby: head - activerecord: 8.0 ruby: 3.1 + - activerecord: 8.1 + ruby: 3.1 - activerecord: head ruby: 3.1 From 9ede99d0dba4be88bc3b86edc9f3de8b37cb8812 Mon Sep 17 00:00:00 2001 From: Leszek Zalewski Date: Wed, 18 Nov 2026 15:30:49 +0100 Subject: [PATCH 3/8] Fix CI: add AR 8.1 gemfile, pin minitest ~> 5.27, install apt deps before bundle --- .github/workflows/test.yml | 8 ++- Appraisals | 4 ++ Gemfile.lock | 9 +-- gemfiles/activerecord_7.2.gemfile.lock | 4 +- gemfiles/activerecord_8.0.gemfile.lock | 6 +- gemfiles/activerecord_8.1.gemfile | 7 ++ gemfiles/activerecord_8.1.gemfile.lock | 92 +++++++++++++++++++++++++ gemfiles/activerecord_head.gemfile.lock | 6 +- lhm.gemspec | 3 +- 9 files changed, 120 insertions(+), 19 deletions(-) create mode 100644 gemfiles/activerecord_8.1.gemfile create mode 100644 gemfiles/activerecord_8.1.gemfile.lock diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ba158efa..b4917e28 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -37,14 +37,16 @@ jobs: steps: - uses: actions/checkout@v4 + + # Native gem extensions (mysql2, trilogy) are built during bundler-cache, so headers must exist first + - name: Install Ubuntu packages + run: sudo apt-get update && sudo apt-get install numactl libaio-dev libmysqlclient-dev libssl-dev + - uses: ruby/setup-ruby@v1 with: ruby-version: ${{matrix.ruby}} bundler-cache: true - - name: Install Ubuntu packages - run: sudo apt-get update && sudo apt-get install numactl libaio-dev libmysqlclient-dev - - name: Setup MySQL and ProxySQL (docker-compose) # Might have to change to docker compose up -d (i.e. Compose V2) when the Ubuntu image changes the docker-compose version run: docker compose -f docker-compose-mysql-${{ matrix.mysql }}.yml up -d diff --git a/Appraisals b/Appraisals index 5ac75187..843d8d9e 100644 --- a/Appraisals +++ b/Appraisals @@ -6,6 +6,10 @@ appraise "activerecord-8.0" do gem "activerecord", "8.0.1" end +appraise "activerecord-8.1" do + gem "activerecord", "8.1.4.1" +end + appraise "activerecord-head" do gem "activerecord", git: "https://github.com/rails/rails.git", branch: "main" end diff --git a/Gemfile.lock b/Gemfile.lock index cfc27faf..dbaa4a7e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -43,17 +43,12 @@ GEM io-console (0.9.5) json (3.1.0) logger (1.7.0) - minitest (6.1.0) - drb (~> 2.0) - prism (>= 1.5, < 3) + minitest (5.27.0) mocha (3.1.0) ruby2_keywords (>= 0.0.5) mysql2 (0.5.7) bigdecimal ostruct (0.6.3) - prism (2.1.0-arm64-darwin) - prism (2.1.0-x86_64-darwin) - prism (2.1.0-x86_64-linux-gnu) rake (13.4.2) reline (0.7.0) io-console (~> 0.5) @@ -84,7 +79,7 @@ DEPENDENCIES byebug lhm-shopify! logger - minitest + minitest (~> 5.27) mocha mysql2 ostruct diff --git a/gemfiles/activerecord_7.2.gemfile.lock b/gemfiles/activerecord_7.2.gemfile.lock index addbd25e..5edcb3d8 100644 --- a/gemfiles/activerecord_7.2.gemfile.lock +++ b/gemfiles/activerecord_7.2.gemfile.lock @@ -41,7 +41,7 @@ GEM i18n (1.14.7) concurrent-ruby (~> 1.0) logger (1.6.5) - minitest (5.25.4) + minitest (5.27.0) mocha (2.1.0) ruby2_keywords (>= 0.0.5) mysql2 (0.5.5) @@ -77,7 +77,7 @@ DEPENDENCIES byebug lhm-shopify! logger - minitest + minitest (~> 5.27) mocha mysql2 ostruct diff --git a/gemfiles/activerecord_8.0.gemfile.lock b/gemfiles/activerecord_8.0.gemfile.lock index 8217011a..90add710 100644 --- a/gemfiles/activerecord_8.0.gemfile.lock +++ b/gemfiles/activerecord_8.0.gemfile.lock @@ -38,11 +38,11 @@ GEM concurrent-ruby (1.3.5) connection_pool (2.5.0) docile (1.4.0) - drb (2.2.1) + drb (2.2.3) i18n (1.14.1) concurrent-ruby (~> 1.0) logger (1.6.1) - minitest (5.22.2) + minitest (5.27.0) mocha (2.1.0) ruby2_keywords (>= 0.0.5) mysql2 (0.5.5) @@ -79,7 +79,7 @@ DEPENDENCIES byebug lhm-shopify! logger - minitest + minitest (~> 5.27) mocha mysql2 ostruct diff --git a/gemfiles/activerecord_8.1.gemfile b/gemfiles/activerecord_8.1.gemfile new file mode 100644 index 00000000..45dfe6b2 --- /dev/null +++ b/gemfiles/activerecord_8.1.gemfile @@ -0,0 +1,7 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "activerecord", "8.1.4.1" + +gemspec path: "../" diff --git a/gemfiles/activerecord_8.1.gemfile.lock b/gemfiles/activerecord_8.1.gemfile.lock new file mode 100644 index 00000000..76db9487 --- /dev/null +++ b/gemfiles/activerecord_8.1.gemfile.lock @@ -0,0 +1,92 @@ +PATH + remote: .. + specs: + lhm-shopify (4.5.1) + retriable (>= 3.0.0) + +GEM + remote: https://rubygems.org/ + specs: + activemodel (8.1.4.1) + activesupport (= 8.1.4.1) + activerecord (8.1.4.1) + activemodel (= 8.1.4.1) + activesupport (= 8.1.4.1) + timeout (>= 0.4.0) + activesupport (8.1.4.1) + base64 + bigdecimal + concurrent-ruby (~> 1.0, >= 1.3.1) + connection_pool (>= 2.2.5) + drb + i18n (>= 1.6, < 2) + json + logger (>= 1.4.2) + 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.3.0) + bigdecimal (4.1.3) + byebug (11.1.3) + concurrent-ruby (1.3.8) + connection_pool (3.0.3) + docile (1.4.0) + drb (2.2.3) + i18n (1.15.2) + concurrent-ruby (~> 1.0) + json (3.1.0) + logger (1.7.0) + minitest (5.27.0) + 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.3.2) + timeout (0.6.1) + toxiproxy (2.0.2) + trilogy (2.9.0) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + uri (1.1.2) + +PLATFORMS + arm64-darwin-21 + arm64-darwin-22 + arm64-darwin-23 + x86_64-darwin-20 + x86_64-linux + +DEPENDENCIES + activerecord (= 8.1.4.1) + after_do + appraisal + byebug + lhm-shopify! + logger + minitest (~> 5.27) + mocha + mysql2 + ostruct + rake + simplecov + toxiproxy + trilogy + +BUNDLED WITH + 2.6.3 diff --git a/gemfiles/activerecord_head.gemfile.lock b/gemfiles/activerecord_head.gemfile.lock index 3fb89740..3b66140c 100644 --- a/gemfiles/activerecord_head.gemfile.lock +++ b/gemfiles/activerecord_head.gemfile.lock @@ -44,11 +44,11 @@ GEM concurrent-ruby (1.3.5) connection_pool (2.5.0) docile (1.4.1) - drb (2.2.1) + drb (2.2.3) i18n (1.14.7) concurrent-ruby (~> 1.0) logger (1.6.5) - minitest (5.25.4) + minitest (5.27.0) mocha (2.4.5) ruby2_keywords (>= 0.0.5) mysql2 (0.5.6) @@ -83,7 +83,7 @@ DEPENDENCIES byebug lhm-shopify! logger - minitest + minitest (~> 5.27) mocha mysql2 ostruct diff --git a/lhm.gemspec b/lhm.gemspec index 559e3022..48eded27 100644 --- a/lhm.gemspec +++ b/lhm.gemspec @@ -26,7 +26,8 @@ Gem::Specification.new do |s| s.add_dependency 'retriable', '>= 3.0.0' s.add_development_dependency 'activerecord' - s.add_development_dependency 'minitest' + # minitest 6 depends on prism, whose native gems need Ruby >= 3.3 and < head; 5.27 covers Ruby 3.1 through 4.x + s.add_development_dependency 'minitest', '~> 5.27' s.add_development_dependency 'mocha' s.add_development_dependency 'after_do' s.add_development_dependency 'rake' From 11fdcb3848f9a815cf1f5c67599621fad5b03a70 Mon Sep 17 00:00:00 2001 From: Leszek Zalewski Date: Wed, 18 Nov 2026 15:39:44 +0100 Subject: [PATCH 4/8] Fix flaky reconnect spec: disable proxy synchronously before first chunk insert --- spec/integration/lhm_spec.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/spec/integration/lhm_spec.rb b/spec/integration/lhm_spec.rb index 747d88e1..80dda182 100644 --- a/spec/integration/lhm_spec.rb +++ b/spec/integration/lhm_spec.rb @@ -729,17 +729,19 @@ table_create(:users) 100.times { |n| execute("insert into users set reference = '#{ n }'") } - # Redeclare Lhm::ChunkInsert to use Hook to disable MySQL writer for 3 seconds before first insert + # Redeclare Lhm::ChunkInsert to use Hook to disable MySQL writer for 3 seconds before first insert. + # The proxy is disabled synchronously so the insert always hits the outage; disabling it from the + # background thread races with the insert and can push the outage onto non-retried queries. Lhm::ChunkInsert.class_eval do extend AfterDo before(:insert_and_return_count_of_rows_created) do unless mysql_disabled mysql_disabled = true + Toxiproxy[:mysql_master].disable Thread.new do - Toxiproxy[:mysql_master].down do - sleep 3 - end + sleep 3 + Toxiproxy[:mysql_master].enable end end end From 57466d8098135630546b9d8139d35d278d5b4fea Mon Sep 17 00:00:00 2001 From: Leszek Zalewski Date: Wed, 18 Nov 2026 15:41:43 +0100 Subject: [PATCH 5/8] CI: pin runner to ubuntu-24.04 (Ruby 3.2 trilogy build fails on 26.04) --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b4917e28..ddb2f24c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,7 +9,8 @@ on: jobs: test: name: Run tests - runs-on: ubuntu-latest + # ubuntu-26.04: trilogy fails to link -lcrypto with the Ruby 3.2 toolcache build + runs-on: ubuntu-24.04 strategy: fail-fast: false From 309f1a88485fdf37c3e0ca3d2c7d62a46c3b690a Mon Sep 17 00:00:00 2001 From: Leszek Zalewski Date: Wed, 18 Nov 2026 16:01:56 +0100 Subject: [PATCH 6/8] Bump bundler to 4.0.24 for AR 8.0/8.1/head lockfiles (2.6.3 breaks on ruby-head) --- gemfiles/activerecord_8.0.gemfile.lock | 2 +- gemfiles/activerecord_8.1.gemfile.lock | 2 +- gemfiles/activerecord_head.gemfile.lock | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gemfiles/activerecord_8.0.gemfile.lock b/gemfiles/activerecord_8.0.gemfile.lock index 90add710..abab88fd 100644 --- a/gemfiles/activerecord_8.0.gemfile.lock +++ b/gemfiles/activerecord_8.0.gemfile.lock @@ -89,4 +89,4 @@ DEPENDENCIES trilogy BUNDLED WITH - 2.6.3 + 4.0.24 diff --git a/gemfiles/activerecord_8.1.gemfile.lock b/gemfiles/activerecord_8.1.gemfile.lock index 76db9487..92390c56 100644 --- a/gemfiles/activerecord_8.1.gemfile.lock +++ b/gemfiles/activerecord_8.1.gemfile.lock @@ -89,4 +89,4 @@ DEPENDENCIES trilogy BUNDLED WITH - 2.6.3 + 4.0.24 diff --git a/gemfiles/activerecord_head.gemfile.lock b/gemfiles/activerecord_head.gemfile.lock index 3b66140c..bb18b03d 100644 --- a/gemfiles/activerecord_head.gemfile.lock +++ b/gemfiles/activerecord_head.gemfile.lock @@ -93,4 +93,4 @@ DEPENDENCIES trilogy BUNDLED WITH - 2.6.3 + 4.0.24 From e97db536184845df53d72150b664c3eeba269110 Mon Sep 17 00:00:00 2001 From: Leszek Zalewski Date: Wed, 18 Nov 2026 16:22:12 +0100 Subject: [PATCH 7/8] Bump byebug to 13.0.0 in AR 8.0/8.1/head lockfiles (11.x fails to compile on ruby-head) --- gemfiles/activerecord_8.0.gemfile.lock | 6 +++++- gemfiles/activerecord_8.1.gemfile.lock | 6 +++++- gemfiles/activerecord_head.gemfile.lock | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/gemfiles/activerecord_8.0.gemfile.lock b/gemfiles/activerecord_8.0.gemfile.lock index abab88fd..449ff315 100644 --- a/gemfiles/activerecord_8.0.gemfile.lock +++ b/gemfiles/activerecord_8.0.gemfile.lock @@ -34,13 +34,15 @@ GEM base64 (0.2.0) benchmark (0.4.0) bigdecimal (3.1.9) - byebug (11.1.3) + byebug (13.0.0) + reline (>= 0.6.0) concurrent-ruby (1.3.5) connection_pool (2.5.0) docile (1.4.0) drb (2.2.3) i18n (1.14.1) concurrent-ruby (~> 1.0) + io-console (0.9.5) logger (1.6.1) minitest (5.27.0) mocha (2.1.0) @@ -48,6 +50,8 @@ GEM mysql2 (0.5.5) ostruct (0.6.1) rake (13.0.6) + reline (0.7.0) + io-console (~> 0.5) retriable (3.1.2) ruby2_keywords (0.0.5) securerandom (0.4.1) diff --git a/gemfiles/activerecord_8.1.gemfile.lock b/gemfiles/activerecord_8.1.gemfile.lock index 92390c56..55de55d2 100644 --- a/gemfiles/activerecord_8.1.gemfile.lock +++ b/gemfiles/activerecord_8.1.gemfile.lock @@ -33,13 +33,15 @@ GEM thor (>= 0.14.0) base64 (0.3.0) bigdecimal (4.1.3) - byebug (11.1.3) + byebug (13.0.0) + reline (>= 0.6.0) concurrent-ruby (1.3.8) connection_pool (3.0.3) docile (1.4.0) drb (2.2.3) i18n (1.15.2) concurrent-ruby (~> 1.0) + io-console (0.9.5) json (3.1.0) logger (1.7.0) minitest (5.27.0) @@ -48,6 +50,8 @@ GEM mysql2 (0.5.5) ostruct (0.6.1) rake (13.0.6) + reline (0.7.0) + io-console (~> 0.5) retriable (3.1.2) ruby2_keywords (0.0.5) securerandom (0.4.1) diff --git a/gemfiles/activerecord_head.gemfile.lock b/gemfiles/activerecord_head.gemfile.lock index bb18b03d..54cd4d06 100644 --- a/gemfiles/activerecord_head.gemfile.lock +++ b/gemfiles/activerecord_head.gemfile.lock @@ -40,13 +40,15 @@ GEM base64 (0.2.0) benchmark (0.4.0) bigdecimal (3.1.9) - byebug (11.1.3) + byebug (13.0.0) + reline (>= 0.6.0) concurrent-ruby (1.3.5) connection_pool (2.5.0) docile (1.4.1) drb (2.2.3) i18n (1.14.7) concurrent-ruby (~> 1.0) + io-console (0.9.5) logger (1.6.5) minitest (5.27.0) mocha (2.4.5) @@ -54,6 +56,8 @@ GEM mysql2 (0.5.6) ostruct (0.6.1) rake (13.2.1) + reline (0.7.0) + io-console (~> 0.5) retriable (3.1.2) ruby2_keywords (0.0.5) securerandom (0.4.1) From 2d3efae57a15261c70f449faf1025164b896bb7b Mon Sep 17 00:00:00 2001 From: Leszek Zalewski Date: Wed, 18 Nov 2026 16:38:20 +0100 Subject: [PATCH 8/8] Fix parallel deletes spec sharing a connection across threads; exclude AR 8.0 on ruby-head --- .github/workflows/test.yml | 3 +++ spec/integration/lhm_spec.rb | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ddb2f24c..9a14d3cc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,6 +25,9 @@ jobs: ruby: head - activerecord: 7.2 ruby: head + # activesupport 8.0 passes `quirks_mode:` to JSON.generate, which ruby-head's json rejects + - activerecord: 8.0 + ruby: head - activerecord: 8.0 ruby: 3.1 - activerecord: 8.1 diff --git a/spec/integration/lhm_spec.rb b/spec/integration/lhm_spec.rb index 80dda182..480c37cf 100644 --- a/spec/integration/lhm_spec.rb +++ b/spec/integration/lhm_spec.rb @@ -669,10 +669,14 @@ it 'should perserve deletes during migration' do 50.times { |n| execute("insert into users set reference = '#{ n }'") } + # Use a separate pooled connection: sharing @connection with the migration interleaves + # protocol packets on one socket if this thread outlives the sleep below. delete = Thread.new do - 10.times do |n| - execute("delete from users where reference = '#{ n }'") - sleep(0.17) + ActiveRecord::Base.connection_pool.with_connection do |conn| + 10.times do |n| + conn.execute("delete from users where reference = '#{ n }'") + sleep(0.17) + end end end sleep 2