From a4a579219afde88125fcd728685f0b69002478fd Mon Sep 17 00:00:00 2001 From: Mitchell Henke Date: Mon, 17 Mar 2025 13:28:15 -0500 Subject: [PATCH] Upgrade good_job changelog: Internal, Maintenance, Upgrade good_job --- Gemfile.lock | 2 +- ...ndex_good_jobs_concurrency_key_created_at.rb | 17 +++++++++++++++++ db/worker_jobs_schema.rb | 3 ++- 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 db/worker_jobs_migrate/20250317182751_add_index_good_jobs_concurrency_key_created_at.rb diff --git a/Gemfile.lock b/Gemfile.lock index 22fb054ed57..6c8e57c4ce0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -352,7 +352,7 @@ GEM ffi (~> 1.0) globalid (1.2.1) activesupport (>= 6.1) - good_job (4.4.2) + good_job (4.9.3) activejob (>= 6.1.0) activerecord (>= 6.1.0) concurrent-ruby (>= 1.3.1) diff --git a/db/worker_jobs_migrate/20250317182751_add_index_good_jobs_concurrency_key_created_at.rb b/db/worker_jobs_migrate/20250317182751_add_index_good_jobs_concurrency_key_created_at.rb new file mode 100644 index 00000000000..1343c8d5cf7 --- /dev/null +++ b/db/worker_jobs_migrate/20250317182751_add_index_good_jobs_concurrency_key_created_at.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddIndexGoodJobsConcurrencyKeyCreatedAt < ActiveRecord::Migration[8.0] + disable_ddl_transaction! + + def change + reversible do |dir| + dir.up do + # Ensure this incremental update migration is idempotent + # with monolithic install migration. + return if connection.index_exists? :good_jobs, [:concurrency_key, :created_at] + end + end + + add_index :good_jobs, [:concurrency_key, :created_at], algorithm: :concurrently + end +end diff --git a/db/worker_jobs_schema.rb b/db/worker_jobs_schema.rb index 2db9037026e..a1328af8a6b 100644 --- a/db/worker_jobs_schema.rb +++ b/db/worker_jobs_schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.0].define(version: 2024_10_22_162624) do +ActiveRecord::Schema[8.0].define(version: 2025_03_17_182751) do # These are extensions that must be enabled in order to support this database enable_extension "pg_catalog.plpgsql" enable_extension "pgcrypto" @@ -91,6 +91,7 @@ t.index ["active_job_id", "created_at"], name: "index_good_jobs_on_active_job_id_and_created_at" t.index ["batch_callback_id"], name: "index_good_jobs_on_batch_callback_id", where: "(batch_callback_id IS NOT NULL)" t.index ["batch_id"], name: "index_good_jobs_on_batch_id", where: "(batch_id IS NOT NULL)" + t.index ["concurrency_key", "created_at"], name: "index_good_jobs_on_concurrency_key_and_created_at" t.index ["concurrency_key"], name: "index_good_jobs_on_concurrency_key_when_unfinished", where: "(finished_at IS NULL)" t.index ["cron_key", "created_at"], name: "index_good_jobs_on_cron_key_and_created_at_cond", where: "(cron_key IS NOT NULL)" t.index ["cron_key", "cron_at"], name: "index_good_jobs_on_cron_key_and_cron_at_cond", unique: true, where: "(cron_key IS NOT NULL)"