hibiken / asynq

Simple, reliable, and efficient distributed task queue in Go
MIT License
10k stars 714 forks source link

[QUESTION] Archived periodic tasks are not triggered on the scheduled run #842

Open sgavinio opened 8 months ago

sgavinio commented 8 months ago

Describe the issue

Hello 👋

When following the advise given here: https://github.com/hibiken/asynq/discussions/376 to specify a fixed task ID to avoid duplicate periodic tasks when having multiple scheduler instances, for example:

task := asynq.NewTask(name, payload,  asynq.TaskID("foo"), asynq.Retention(time.Minute))
_, err := scheduler.Register("* * * * *", task)

Periodic tasks that error out are simply moved to the archived state and are never again triggered on the next schedule.

I can confirm this doesn't happen if the TaskID() option is not specified. Similar to the linked discussion above, we have the scheduler running together with the worker, and where we can have potentially any number of workers depending on the amount of available work.

The only way I've managed to get the task to start again on the next schedule is to manually delete the task (i.e. remove it from archived so it can be re-enqueued again).

We write our background tasks to be completely idempotent so simply running a failed task on the next scheduled run is perfectly fine for us.

Would there be a way to skip the failed periodic tasks from going to archived? It would be ideal if an option similar to Retention() exists (which as I understand only works for completed tasks) for archived tasks.

JeremyCraven commented 3 weeks ago

This would be really nice.