From 7fc4450125dbc9e0d24f1699de89a42936f73412 Mon Sep 17 00:00:00 2001 From: smudge Date: Mon, 2 Feb 2026 14:44:56 -0500 Subject: [PATCH] fix: avoid test flakes on mysql By inserting more rows up front, MySQL will behave more deterministically. (In practice, I was finding that 10 was slightly too few, and doing it on every test query is unnecessary if a single example covers multiple queries.) /no-platform stack-info: PR: https://github.com/Betterment/delayed/pull/90, branch: smudge/stack/1 --- spec/helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/helper.rb b/spec/helper.rb index 066a855..09a09a9 100644 --- a/spec/helper.rb +++ b/spec/helper.rb @@ -311,7 +311,7 @@ def postgresql_explain end def mysql2_explain - seed_rows! # MySQL needs a bit of data to reach for indexes + seed_rows! if Delayed::Job.none? # MySQL needs a bit of data to reach for indexes connection.execute("ANALYZE TABLE #{Delayed::Job.table_name}") connection.execute("SET SESSION max_seeks_for_key = 1") connection.execute("EXPLAIN FORMAT=TREE #{sql}").to_a.map(&:first).join("\n") @@ -325,7 +325,7 @@ def sqlite3_explain def seed_rows! now = Delayed::Job.db_time_now - 10.times do + 100.times do [true, false].repeated_combination(5).each_with_index do |(erroring, failed, locked, future), i| Delayed::Job.create!( run_at: now + (future ? i.minutes : -i.minutes),