mirror of
https://github.com/hibiken/asynq.git
synced 2026-04-25 23:15:51 +03:00
[GH-ISSUE #1079] [FEATURE REQUEST] Prioritized Execution of Failed Retry Tasks #2541
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#2541
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 @HarvestWu on GitHub (Oct 15, 2025).
Original GitHub issue: https://github.com/hibiken/asynq/issues/1079
Originally assigned to: @hibiken, @kamikazechaser on GitHub.
Is your feature request related to a problem? Please describe.
I'm frustrated when a task fails, is scheduled for a retry, and gets placed at the end of a long queue. If the system is processing a backlog of tasks, this failed task must wait for the entire queue to be processed before it can be retried. This can lead to significant delays in processing critical tasks that may have failed due to a transient issue (e.g., a brief network hiccup or a temporary dependency unavailability), effectively causing "starvation" for the retrying task.
Describe the solution you'd like
I would like Asynq to support an option where a task that fails and is scheduled for a retry can be re-queued to the front of its queue, instead of the back. This would ensure that the next available worker picks up the failed task for a retry immediately, minimizing delay. This could be implemented as a new RetryModeor an option when enqueuing a task, for example: asynq.RetryQueueFront().
Describe alternatives you've considered
Additional context
The current behavior, where retries are placed at the back of the queue, is safe for preventing a constantly failing task from blocking the queue. However, a configuration option to prioritize retries would be invaluable for use cases where immediate retry for potentially transient failures is critical for application performance and user experience. This feature is available in other message queue systems and would greatly enhance Asynq's flexibility.
@RychEmrycho commented on GitHub (Dec 11, 2025):
curious, are you clubbing non-critical and critical task in the same queue? if all the task in the queue are in the same level of criticality, then i think its fair for the failed task to wait for its turn after another critical tasks are completed; after all they are in the same level of criticality, right?
maybe, we can also look at from different angle. why a critical task need to wait for long delay, can we speed up the processing of the tasks in general, such as by increasing the consumer instance, increasing the worker size, optimizing the task processing, etc.
additionally, since you mention about network hiccup/transient error then i assume it involving http client components? in that case, you can consider a retrier mechanism for example using heimdall (https://github.com/gojek/heimdall?tab=readme-ov-file#creating-an-http-client-with-a-retry-mechanism), with this you can test a few retry before marking the task failed.
however, im not quite sure about your problem statement in details, if none of the above applies, then perhaps you actually need the functionality 😅