No public API (or index) for querying in-flight jobs by concurrency_key
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 65/100
Hướng nghiên cứu
Look at the ActiveJob::ConcurrencyControls module to understand how concurrency_key is generated and stored. Examine the solid_queue_jobs table schema to see the missing index. The goal is to add a public API method to query jobs by concurrency_key and add an index on that column. Check existing tests for concurrency limits to see how to test the new API.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
SolidQueue::Job#concurrency_key (set via limits_concurrency) already encodes exactly the "is a business-level operation currently running" signal applications need — but there's no supported way to query it, and the column isn't indexed on solid_queue_jobs itself.
The app I work on Quepid has a long running jobs that do "LLM as a Judge"... I want to make sure that I don't accidentally cue up more than one Judge per specific Book. It's okay to have multiple judges work on the same Book. It's okay to have the same judge running twice, for two seperate Books. But not have the same Judge running twice for the same Book.
We wrote some janky code to look this up, and I think it would be nicer if it was part of SolidQueue.
A small part of me wondered if I have to send 1000's of query/doc pairs to evaluate to an LLM, should it be a queue, or is there a different architecture I should have picked?
Current behavior
Any job using limits_concurrency:
class RunJudgeJudyJob < ApplicationJob
limits_concurrency to: 1, key: ->(book, judge, *) { "run_judge_judy_#{book.id}_#{judge.id}" }
end
gets a concurrency_key column populated on its solid_queue_jobs row (confirmed in our own app's DB: "RunJudgeJudyJob/run_judge_judy_1_8"). That's precisely what an app needs to answer "is this book+judge combination currently being judged," or "which judges are active for this book" via a prefix match. But today we have to:
- Recompute the key format ourselves (
"#{class_name}/#{key}"), relying on an undocumented internal format (seeActiveJob::ConcurrencyControls#concurrency_key) that could change without notice. - Query it with
WHERE concurrency_key LIKE '...'against an unindexed column — a full table scan onsolid_queue_jobsas job volume grows. (solid_queue_blocked_executionsalready indexesconcurrency_key;solid_queue_jobsdoes not.) - For anything the key alone doesn't capture (e.g., extracting which argument matched a prefix), fall back to parsing the raw serialized
argumentsJSON per row anyway.
Why this belongs in SolidQueue, not application code
The key is computed and persisted entirely by SolidQueue's own ActiveJob::ConcurrencyControls extension (injected into ActiveJob::Base via SolidQueue::Engine's on_load(:active_job) hook) — there's no adapter-portable way to derive it from outside the gem. Every app using limits_concurrency for a "one active run per business entity" pattern hits this same gap and re-derives the same fragile format independently.
- Ngôn ngữ chính
- Ruby
- Star
- 2.5k
- Fork
- 250
- Merge trung bình
- 8 giờ 31 phút
- Pull request đã merge (30 ngày)
- 5
Chuẩn bị môi trường
Chúng tôi chưa kiểm tra các tệp thiết lập môi trường của dự án này. Hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của rails/solid_queue
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 42/100
rails/solid_queue#808 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
rails/solid_queue#806 ·
-
limits_concurrency on_conflict: :discard looking only into running jobs and not blocked jobsĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 52/100
rails/solid_queue#804 · 1 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
rails/solid_queue#802 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
rails/solid_queue#797 ·
Tất cả issue của rails/solid_queue
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
misa.G should not be definedĐang mởdata error
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
riscv/riscv-unified-db#2648 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
P2 testing
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
Maintainer thường phản hồi trong vòng 1 ngày