quantum-elixir / quantum-core

:watch: Cron-like job scheduler for Elixir
https://hexdocs.pm/quantum/
Apache License 2.0
2.32k stars 148 forks source link

Runtime Tasks queue up and run on re-adding a job #416

Closed overture8 closed 4 years ago

overture8 commented 5 years ago

I'm not sure if this is the expected behaviour... But, after deleting a runtime job, tasks seem to be queued up then executed on re-adding a job with the same name. I'm using Quantum 2.3.4.

Here is an example of what I'm seeing:

# Add job to run every minute
iex> QuantumScheduler.new_job()
|> Quantum.Job.set_name(:ticker)
|> Quantum.Job.set_schedule(~e[* * * * *])
|> Quantum.Job.set_task(fn -> IO.inspect("TICK") end)
|> QuantumScheduler.add_job()

# 1 minute past
"TICK"
# 2 minutes past
"TICK"

iex> QuantumScheduler.delete_job(:ticker)

# 3 minutes past
# 4 minutes past
# 5 minutes past

iex> QuantumScheduler.new_job()
|> Quantum.Job.set_name(:ticker)
|> Quantum.Job.set_schedule(~e[* * * * *])
|> Quantum.Job.set_task(fn -> IO.inspect("TICK") end)
|> QuantumScheduler.add_job()

# Tasks immediately run for minutes 3, 4 and 5 (when the job was deleted above)
# ** This is where I think the issue is **
"TICK"
"TICK"
"TICK"

# 6 minutes past and things continue as normal
"TICK"

Is this the expected behaviour? Once a job is deleted I wouldn't expect it to be queuing up tasks then executing them on re-adding?

TestFirebaseLogin commented 4 years ago

Even im experiencing same issue, is i expected behaviour?Is there a way i can avoid reexecution,if job with same is added again?

overture8 commented 4 years ago

@TestFirebaseLogin Honestly, I had to move away from quantum-core in the end because of this. Not sure if I was doing something wrong or not - but the recurring stuff I was working on was too mission critical to risk using it.

maennchen commented 4 years ago

Sorry about this behavior. I currently lack the time to properly resolve those issues. I'll get back to it some soon I hope.

maennchen commented 4 years ago

Fixed on master, will be released with #427