Skip to content

[FEATURE REQUEST] Prioritized Execution of Failed Retry Tasks #1079

@HarvestWu

Description

@HarvestWu

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

  1. Increasing RetryDelaysignificantly:​​ This doesn't solve the problem; it just spaces out the long waits between retries.
  2. ​​Creating a separate high-priority queue for retries:​​ This is a workaround where I would manually handle failures by enqueuing a new task into a "retry" queue with higher priority. However, this requires complex error handling logic outside of Asynq's built-in retry mechanism and loses the original task's state and history.
  3. Reducing the number of retries and relying on external monitoring to re-enqueue failed tasks:​​ This adds significant operational complexity and is not a robust solution.

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.

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions