Skip to content

Commit d4d4a35

Browse files
committed
Try another workaround to avoid deadlock when dispatching scheduled jobs
Instead of deleting these using the index on `job_id`, do the DELETE relying on the primary key.
1 parent 108aea9 commit d4d4a35

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

app/models/solid_queue/execution/dispatching.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def dispatch_jobs(job_ids)
1010
jobs = Job.where(id: job_ids)
1111

1212
Job.dispatch_all(jobs).map(&:id).tap do |dispatched_job_ids|
13-
where(job_id: dispatched_job_ids).order(:job_id).delete_all
13+
where(id: where(job_id: dispatched_job_ids).pluck(:id)).delete_all
1414
SolidQueue.logger.info("[SolidQueue] Dispatched #{dispatched_job_ids.size} jobs")
1515
end
1616
end

0 commit comments

Comments
 (0)