mirror of
https://github.com/hibiken/asynq.git
synced 2026-04-26 07:25:56 +03:00
[GH-ISSUE #998] [BUG] Some question about priority queue #2503
Labels
No labels
CLI
bug
designing
documentation
duplicate
enhancement
good first issue
good first issue
help wanted
idea
invalid
investigate
needs-more-info
performance
pr-welcome
pull-request
question
wontfix
work in progress
work in progress
work-around-available
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/asynq#2503
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @FelixSeptem on GitHub (Dec 30, 2024).
Original GitHub issue: https://github.com/hibiken/asynq/issues/998
Originally assigned to: @hibiken, @kamikazechaser on GitHub.
Describe the bug
When I choose to use the multi queue with priority, I was curious about the implementation mechanism. So I dig the code in, and seek it in the
queuesmethod of theprocessor, which is https://github.com/hibiken/asynq/blob/master/processor.go#L399I wondering
priorityvariable only affects the composition of the names list and does not affect the final returned queue list. The final queue list is unduplicated and the queues in the configuration are selected with equal probability, rather than increasing the probability of some queues being selected by priority.Suggestion
Modify
uniqfunction to conclude priority infactors, I will happy to create a pull request if need.@ganlvtech commented on GitHub (Jul 7, 2025):
shuffle and uniq will sort the names by probabilities. It got random order by the
priority. And theDequeueoperation is done one by one.github.com/hibiken/asynq@c327bc40a2/internal/rdb/rdb.go (L240-L274)If there are 3 names "a", "b", "c", and probabilities are a🅱️c, then you will get P(a_before_b):P(b_before_a) = a:b
I don't think there is a bug here.