From 1d17c670b8ac7d399d6381590eaa0d27ccefae65 Mon Sep 17 00:00:00 2001 From: Javi R <4920956+rameerez@users.noreply.github.com> Date: Sun, 16 Aug 2026 20:18:34 +0100 Subject: [PATCH] Example migration check: primary-only, never walk every pool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ActiveRecord::Migration.check_all_pending! iterates EVERY configured connection pool. In a Solid-Queue/Cache/Cable app the cache pool is hot on every request, so under load the check blocks on pool checkout and a healthy page drifts into check-timeout territory. Measured in production: 122ms idle, >10s under traffic — a false ❌ from the example everyone copies. The replacement checks the primary pool's migration context, read-only, ~7ms, and asks the question the tripwire actually means: did a deploy land with pending schema migrations. Co-Authored-By: Claude Fable 5 --- README.md | 7 ++++++- examples/allgood.rb | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 76909cb..7feb4df 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,12 @@ check "Database can perform a simple query" do end check "Database migrations are up to date" do - make_sure ActiveRecord::Migration.check_all_pending! == nil + # Primary database only, read-only, ~ms. Deliberately NOT + # ActiveRecord::Migration.check_all_pending! — that walks EVERY configured + # connection pool (queue/cache/cable in a Solid-* app) and blocks on pool + # checkout under load, which can push a healthy page into check-timeout + # territory. Seen in production: 122ms idle, >10s under traffic. + make_sure !ActiveRecord::Base.connection.pool.migration_context.needs_migration? end check "Disk space usage is below 90%" do diff --git a/examples/allgood.rb b/examples/allgood.rb index ecca106..c7ebfc6 100644 --- a/examples/allgood.rb +++ b/examples/allgood.rb @@ -38,7 +38,12 @@ end check "Database migrations are up to date" do - make_sure ActiveRecord::Migration.check_all_pending! == nil + # Primary database only, read-only, ~ms. Deliberately NOT + # ActiveRecord::Migration.check_all_pending! — that walks EVERY configured + # connection pool (queue/cache/cable in a Solid-* app) and blocks on pool + # checkout under load, which can push a healthy page into check-timeout + # territory. Seen in production: 122ms idle, >10s under traffic. + make_sure !ActiveRecord::Base.connection.pool.migration_context.needs_migration? end # --- IMAGE PROCESSING ---