[GH-ISSUE #629] [FEATURE REQUEST] Add ability to remove unique tasks on error #307

Open
opened 2026-03-02 05:20:22 +03:00 by kerem · 1 comment
Owner

Originally created by @lexuzieel on GitHub (Mar 19, 2023).
Original GitHub issue: https://github.com/hibiken/asynq/issues/629

Originally assigned to: @hibiken on GitHub.

Is your feature request related to a problem? Please describe.
In my project I run scheduled tasks with drastically varying execution times, so I schedule them to run every minute and tried to use unique option in order to have "no-overlap" logic.
However, since currently unique lock is only released on successful completion, in case my task ends with an error I have a dangling
unique task indefinitely (in order to achieve no overlapping I set unique TTL to a large amount - like an hour).

Describe the solution you'd like
I would like to have an option to tell that unique lock should be released on task error.

Describe alternatives you've considered
Currently the only option I see is to manually remove the task using Inspector at the end of processor handler.

Additional context
Coming from Laravel, it has a concept of "without overlapping" job scheduling: https://laravel.com/docs/10.x/queues#preventing-job-overlaps

Originally created by @lexuzieel on GitHub (Mar 19, 2023). Original GitHub issue: https://github.com/hibiken/asynq/issues/629 Originally assigned to: @hibiken on GitHub. **Is your feature request related to a problem? Please describe.** In my project I run scheduled tasks with drastically varying execution times, so I schedule them to run every minute and tried to use unique option in order to have "no-overlap" logic. However, since currently unique lock is only released on successful completion, in case my task ends with an error I have a dangling unique task indefinitely (in order to achieve no overlapping I set unique TTL to a large amount - like an hour). **Describe the solution you'd like** I would like to have an option to tell that unique lock should be released on task error. **Describe alternatives you've considered** Currently the only option I see is to manually remove the task using `Inspector` at the end of processor handler. **Additional context** Coming from Laravel, it has a concept of "without overlapping" job scheduling: https://laravel.com/docs/10.x/queues#preventing-job-overlaps
Author
Owner

@kamikazechaser commented on GitHub (Mar 23, 2023):

Better to use a distributed lock mechanism like https://github.com/bsm/redislock then defer release the lock in the task handler.

<!-- gh-comment-id:1480704459 --> @kamikazechaser commented on GitHub (Mar 23, 2023): Better to use a distributed lock mechanism like https://github.com/bsm/redislock then defer release the lock in the task handler.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/asynq#307
No description provided.