From a07e6667b4386887bee2b8dda6a5fd853015fbb0 Mon Sep 17 00:00:00 2001 From: evazion Date: Wed, 30 Nov 2022 17:29:30 -0600 Subject: [PATCH] jobs: fix backwards job priorities. Fix bug where jobs had the opposite of the intended priority. Populating saved searches had the highest priority, while processing uploads had the lowest priority. Caused by Delayed::Job and GoodJob having opposite interpretations of job priorities. In Delayed::Job, lower numbers had higher priority, while in GoodJob, higher numbers have higher priority. This was missed when migrating from Delayed::Job to GoodJob. --- app/jobs/application_job.rb | 2 ++ app/jobs/delete_favorites_job.rb | 1 - app/jobs/delete_user_job.rb | 1 - app/jobs/populate_saved_search_job.rb | 2 +- app/jobs/process_upload_job.rb | 2 +- app/jobs/process_upload_media_asset_job.rb | 2 +- app/jobs/regenerate_post_job.rb | 1 - 7 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb index 7a008029d..8fde78f02 100644 --- a/app/jobs/application_job.rb +++ b/app/jobs/application_job.rb @@ -11,6 +11,8 @@ class ApplicationJob < ActiveJob::Base class JobTimeoutError < StandardError; end queue_as :default + + # Jobs with higher priority are processed first. Higher number = higher priority. queue_with_priority 0 around_perform do |_job, block| diff --git a/app/jobs/delete_favorites_job.rb b/app/jobs/delete_favorites_job.rb index d1635b06e..d8d6212dd 100644 --- a/app/jobs/delete_favorites_job.rb +++ b/app/jobs/delete_favorites_job.rb @@ -3,7 +3,6 @@ # A job that deletes a user's favorites when they delete their account. class DeleteFavoritesJob < ApplicationJob queue_as :default - queue_with_priority 20 def perform(user) Post.without_timeout do diff --git a/app/jobs/delete_user_job.rb b/app/jobs/delete_user_job.rb index 7a8e576ab..eb3220ba0 100644 --- a/app/jobs/delete_user_job.rb +++ b/app/jobs/delete_user_job.rb @@ -3,7 +3,6 @@ # A job that deletes a user's settings and other personal data when they delete their account. class DeleteUserJob < ApplicationJob queue_as :default - queue_with_priority 20 def perform(user) UserDeletion.new(user: user).delete_user diff --git a/app/jobs/populate_saved_search_job.rb b/app/jobs/populate_saved_search_job.rb index 08434876f..70b381153 100644 --- a/app/jobs/populate_saved_search_job.rb +++ b/app/jobs/populate_saved_search_job.rb @@ -4,7 +4,7 @@ # `search:all` or `search: