Add a per-class delete button for mixed queues
#1969 adds a Delete button to each row of a queue's pending-jobs page. It deliberately stops there. The case it does not cover is a mixed-class queue where you want to drop one class and keep the others.
Neither existing option fits that:
- Remove Queue takes everything, regardless of class. It is very cheap — one pipelined
SREMplusUNLINK, constant work whatever the queue depth — so it is the right tool when you want the queue gone, and usually the right answer in practice. - The per-row button from #1969 deletes by exact payload, which is fine for a handful of rows and unusable for thousands.
Why this is blocked rather than just unwritten
The obvious implementation is Job.destroy(queue, klass) with no args, and that is the expensive branch:
data_store.everything_in_queue(queue).each do |string| # LRANGE 0 -1, whole queue into a Ruby array
if decode(string)['class'] == klass
destroyed += data_store.remove_from_queue(queue, string).to_i # O(N) LREM, once per match
end
endEvery payload in the queue gets loaded into memory, then each match costs a linear scan of the list. Putting that behind a one-click button in the web UI turns a deep queue into an incident. That is a much worse shape than Remove Queue, which is what an operator would otherwise reach for.
So this should wait on a destroy that does not load the queue into memory — #1788 (nevans) is aiming at exactly that. Once a bounded-memory destroy exists, a per-class button becomes a small, safe addition rather than a foot-gun.
Shape, when it is unblocked
- Something like
Job.list_job_classes(queue)to render classes with counts. #1732 (h3nnn4n) had a version of this; worth borrowing with credit. - A delete control per class, on the queue page.
- Confirmation, since it is destructive and broader than the per-row button.
- Worth deciding whether it unwraps
ActiveJob::QueueAdapters::ResqueAdapter::JobWrapperso an Active Job shop sees real job classes instead of oneJobWrapperrow — #1732 did, and it is still the correct constant. Related to #1968.
Related: #1969 (per-row deletion), #1788 (low-memory destroy, the blocker), #1732 (original bundled attempt), #1968.
Source: resque/resque