mirror of
https://github.com/hibiken/asynq.git
synced 2026-04-25 23:15:51 +03:00
[GH-ISSUE #273] [FEATURE REQUEST] Returning Task Back to Queue #106
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#106
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 @andrey-ryoo on GitHub (May 18, 2021).
Original GitHub issue: https://github.com/hibiken/asynq/issues/273
Originally assigned to: @hibiken on GitHub.
Hi, I suggest this feature might be useful.
Problem: The worker is out of resources because of heavy task and it's good idea to return it back to queue.
Example:
This shouldn't be counted as error and tries not to break API, but honestly I'd return
(map[string]interface, error)@hibiken commented on GitHub (May 20, 2021):
@andrey-ryoo Thank you for opening this issue!
(Let me make sure I understand your issue) You want to return a sentinel error value to indicate not to increment retry count, is that correct?
But alternatively, If you expect the task to fail, you can increase the number of max retry using
MaxRetryoption; would that approach work for you?@andrey-ryoo commented on GitHub (May 21, 2021):
My point is the task should have 3 statuses. 1. Success, 2. Unable to handle(if condition say, don’t even start), 3. Error during execution.
1 and 3 is well implemented and I suggest implementing 2.
@hibiken commented on GitHub (May 21, 2021):
Ok, thanks for clarifying.
Here's my initial solution.
Proposal
We can introduce a sentinel error
ErrFailedPreconditionwhich indicates to the asynq server not to increment the retried-counter but enqueues the task back for later processing.Example
Asynq server should check for the returned error and if
is true, do not increment retried-count but enqueue the task back for later processing (Task will be in retry-state)
Let me know if you have thoughts on this.
@andrey-ryoo commented on GitHub (May 22, 2021):
That’s exactly what I mentioned. The error needs to be built in as constant
@flamedmg commented on GitHub (Jun 9, 2021):
One of the possible uses i encounter is API limits. Say some api endpoints have call limits, say 100 call per minute. Will this help to solve situations like this?
@gopkg-dev commented on GitHub (Jun 9, 2021):
Me too. I need to put the task back in the queue.
@crossworth commented on GitHub (Aug 19, 2021):
Would be cool if we could specify a ProcessIn (or at) as well, since some APIs return a
retry after xwhen reaching the rate limit and some libraries returns this as a custom error.Maybe something like:
@sdklab007 commented on GitHub (Aug 24, 2021):
@hibiken Even I am looking for a similar solution proposed by @crossworth.
@hibiken commented on GitHub (Aug 25, 2021):
To answer @crossworth's comment,
We have
RetryDelayFuncwhich can be configured when you create a Server instance via config.You could return a custom error and handle it in your RetryDelayFunc like so:
Going back to the original question from @andrey-ryoo, we could use a similar approach and we can add
IsFailure(err error) boolto the server's config and allow user to provide that function.Example: