[GH-ISSUE #306] [BUG] Scheduler enqueuing tasks too many times #125

Closed
opened 2026-03-02 05:18:53 +03:00 by kerem · 2 comments
Owner

Originally created by @JeremyCraven on GitHub (Aug 4, 2021).
Original GitHub issue: https://github.com/hibiken/asynq/issues/306

Originally assigned to: @hibiken on GitHub.

Describe the bug
This may not be a bug, but I'm opening this so hopefully I can understand this behavior. Running asynq 0.16.
I have a periodic task with the following cron spec * 0 * * *. I would expect this to enqueue 1 task in a 24 hour period. Looking at the history in the UI the task got enqueued 22 times in a short period of time and then stopped getting enqueued. Attached are screenshots showing the behavior observed. Hopefully this is just user error, but I'd appreciate any guidance. Thanks!

To Reproduce
I'm not sure if I can reproduce this, but it has happened on multiple occasions.

  1. Register a periodic task with the cron spec * 0 * * *
  2. Wait until the task is scheduled to be enqueued
  3. See it getting enqueued many more times than once

Expected behavior
This task should be enqueued once a day according to the cron spec.

Environment (please complete the following information):

  • asynq v0.16.0

Screenshots
Screen Shot 2021-08-04 at 9 55 44 AM

Screen Shot 2021-08-04 at 9 56 00 AM
Originally created by @JeremyCraven on GitHub (Aug 4, 2021). Original GitHub issue: https://github.com/hibiken/asynq/issues/306 Originally assigned to: @hibiken on GitHub. **Describe the bug** This may not be a bug, but I'm opening this so hopefully I can understand this behavior. Running asynq 0.16. I have a periodic task with the following cron spec `* 0 * * *`. I would expect this to enqueue 1 task in a 24 hour period. Looking at the history in the UI the task got enqueued 22 times in a short period of time and then stopped getting enqueued. Attached are screenshots showing the behavior observed. Hopefully this is just user error, but I'd appreciate any guidance. Thanks! **To Reproduce** I'm not sure if I can reproduce this, but it has happened on multiple occasions. 1. Register a periodic task with the cron spec `* 0 * * *` 2. Wait until the task is scheduled to be enqueued 3. See it getting enqueued many more times than once **Expected behavior** This task should be enqueued once a day according to the cron spec. **Environment (please complete the following information):** - asynq v0.16.0 **Screenshots** <img width="510" alt="Screen Shot 2021-08-04 at 9 55 44 AM" src="https://user-images.githubusercontent.com/8557970/128223424-6fd91f31-e36b-4c71-940f-20296aa04c2a.png"> <img width="1217" alt="Screen Shot 2021-08-04 at 9 56 00 AM" src="https://user-images.githubusercontent.com/8557970/128223500-f2d01a8d-0730-46a3-ab43-6faa6b3d9bb8.png">
kerem 2026-03-02 05:18:53 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@crossworth commented on GitHub (Aug 4, 2021):

Hello @JeremyCraven.

I think I see the problem:

  • First using * 0 * * * you are telling At every minute past hour 0.
  • Unique: The uniqueness lock has a TTL associated with it to avoid holding the lock forever. The lock will be released after the TTL or if the task holding the lock gets processed successfully before the TTL.

Is possible that you enqueue the task, but it gets processed in a few seconds and the scheduler adds it back to the queue since the unique lock is released?

Maybe changing to 0 0 * * * - At 00:00 solves the problem.

<!-- gh-comment-id:892849232 --> @crossworth commented on GitHub (Aug 4, 2021): Hello @JeremyCraven. I think I see the problem: - First using `* 0 * * *` you are telling [`At every minute past hour 0`](https://crontab.guru/#*_0_*_*_*). - [Unique](https://github.com/hibiken/asynq/wiki/Unique-Tasks): `The uniqueness lock has a TTL associated with it to avoid holding the lock forever. The lock will be released after the TTL or if the task holding the lock gets processed successfully before the TTL.` Is possible that you enqueue the task, but it gets processed in a few seconds and the scheduler adds it back to the queue since the unique lock is released? Maybe changing to [`0 0 * * *` - At 00:00](https://crontab.guru/#0_0_*_*_*) solves the problem.
Author
Owner

@JeremyCraven commented on GitHub (Aug 4, 2021):

Thanks! Definitely user error. Closing this out. Appreciate the quick response!

<!-- gh-comment-id:892859214 --> @JeremyCraven commented on GitHub (Aug 4, 2021): Thanks! Definitely user error. Closing this out. Appreciate the quick response!
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#125
No description provided.