diff --git a/Gemfile b/Gemfile index 2c471299..2e3b4003 100644 --- a/Gemfile +++ b/Gemfile @@ -15,7 +15,7 @@ gem 'active_model_serializers', '~> 0.10' gem 'bcrypt', '~> 3.1' # Use GoodJob as our Active Job queue adapter -gem 'good_job', '~> 3.22' +gem 'good_job', '~> 3.23' gem 'wahwah', '~> 1.5.1' diff --git a/Gemfile.lock b/Gemfile.lock index 79a3ca10..aac4b1fd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -120,7 +120,7 @@ GEM raabro (~> 1.4) globalid (1.2.1) activesupport (>= 6.1) - good_job (3.22.0) + good_job (3.23.0) activejob (>= 6.0.0) activerecord (>= 6.0.0) concurrent-ruby (>= 1.0.2) @@ -291,7 +291,7 @@ DEPENDENCIES debug (~> 1.9) factory_bot_rails (~> 6.4) faker (~> 3.2) - good_job (~> 3.22) + good_job (~> 3.23) has_scope (~> 0.8) image_processing (~> 1.12.2) mocha (~> 2.1.0) diff --git a/db/migrate/20240127110542_create_index_good_job_jobs_for_candidate_lookup.rb b/db/migrate/20240127110542_create_index_good_job_jobs_for_candidate_lookup.rb new file mode 100644 index 00000000..70e52562 --- /dev/null +++ b/db/migrate/20240127110542_create_index_good_job_jobs_for_candidate_lookup.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class CreateIndexGoodJobJobsForCandidateLookup < ActiveRecord::Migration[7.1] + 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_name_exists?(:good_jobs, :index_good_job_jobs_for_candidate_lookup) + end + end + + add_index :good_jobs, [:priority, :created_at], order: { priority: "ASC NULLS LAST", created_at: :asc }, + where: "finished_at IS NULL", name: :index_good_job_jobs_for_candidate_lookup, + algorithm: :concurrently + end +end diff --git a/db/schema.rb b/db/schema.rb index b7b98b33..aba59cdf 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_01_06_103261) do +ActiveRecord::Schema[7.1].define(version: 2024_01_27_110542) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -227,6 +227,7 @@ 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)" t.index ["finished_at"], name: "index_good_jobs_jobs_on_finished_at", where: "((retried_good_job_id IS NULL) AND (finished_at IS NOT NULL))" t.index ["labels"], name: "index_good_jobs_on_labels", where: "(labels IS NOT NULL)", using: :gin + t.index ["priority", "created_at"], name: "index_good_job_jobs_for_candidate_lookup", where: "(finished_at IS NULL)" t.index ["priority", "created_at"], name: "index_good_jobs_jobs_on_priority_created_at_when_unfinished", order: { priority: "DESC NULLS LAST" }, where: "(finished_at IS NULL)" t.index ["queue_name", "scheduled_at"], name: "index_good_jobs_on_queue_name_and_scheduled_at", where: "(finished_at IS NULL)" t.index ["scheduled_at"], name: "index_good_jobs_on_scheduled_at", where: "(finished_at IS NULL)" diff --git a/gemset.nix b/gemset.nix index 8569067c..869a7f03 100644 --- a/gemset.nix +++ b/gemset.nix @@ -389,10 +389,10 @@ platforms = []; source = { remotes = ["https://rubygems.org"]; - sha256 = "1f99c8xy3ljjg4zk1vsvlxxh5in0hwl7zbhgknhlfghf23cgnsj9"; + sha256 = "1q23jivdanf3n3vkxklhrpapac2jqhx9znn27my84fl8wfqjjcyp"; type = "gem"; }; - version = "3.22.0"; + version = "3.23.0"; }; has_scope = { dependencies = ["actionpack" "activesupport"];