Skip to content

Possible scheduled tasks duplication #244

@stinovlas

Description

@stinovlas

As far as I know, current design of scheduler works like this:

  1. send all tasks that are scheduled to current minute
  2. wait until next minute start (while asynchronously keeping an eye on scheduled tasks)
  3. repeat send with delays with one minute interval

This creates a possible duplication of tasks. If I restart scheduler in a minute where there is a cron scheduled task, this task is sent twice (once before the restart and once after). On the other hand, it allows the scheduler to be restarted without missing a task, assuming the restart takes less then one minute to perform (which is quite reasonable assumption for scheduler).

Ideally, tasks should be idempotent, but that's not always possible. It would be great if taskiq kept in mind whether particular task has already been sent to worker queue in one minute and if so, wouldn't send it again after restart. This is obviously not possible with LabelScheduleSource since it doesn't have any permanent storage, but it might be possible with taskiq_redis.RedisScheduleSource.

What do you think about this? Should I propose an enhancement in taskiq_redis? Does something need to be done in taskiq itself?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions