quantum-elixir / quantum-core

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

Gigalixir GenServer stopping due to nil schedule #471

Closed sfsekaran closed 2 years ago

sfsekaran commented 3 years ago

Not certain what's going on here. Quantum works fine on my local, but on "production" (Gigalixir), Quantum fails with the following backtrace/error.

It seems, after looking at the log, that nil is being passed as the schedule argument, which is why it's failing. But past that I'm not sure why it's doing this.

 web.1  | 09:07:45.762 [error] GenServer Violeta.Scheduler.ExecutionBroadcaster terminating
 web.1  |     (crontab 1.1.10) lib/crontab/scheduler.ex:41: Crontab.Scheduler.get_next_run_date(nil, ~N[2021-01-12 09:07:45], 10000)
 web.1  | ** (FunctionClauseError) no function clause matching in Crontab.Scheduler.get_next_run_date/3
 web.1  |     (quantum 3.3.0) lib/quantum/execution_broadcaster.ex:277: Quantum.ExecutionBroadcaster.get_next_execution_time/2
 web.1  |     (quantum 3.3.0) lib/quantum/execution_broadcaster.ex:248: Quantum.ExecutionBroadcaster.add_job_to_state/3
 web.1  |     (quantum 3.3.0) lib/quantum/execution_broadcaster.ex:182: Quantum.ExecutionBroadcaster.initialize_jobs/2
 web.1  |     (elixir 1.11.3) lib/enum.ex:2193: Enum."-reduce/3-lists^foldl/2-0-"/3
 web.1  |     (quantum 3.3.0) lib/quantum/execution_broadcaster.ex:91: anonymous fn/2 in Quantum.ExecutionBroadcaster.handle_events/3
 web.1  |     (elixir 1.11.3) lib/enum.ex:2193: Enum."-reduce/3-lists^foldl/2-0-"/3
 web.1  |     (quantum 3.3.0) lib/quantum/execution_broadcaster.ex:170: Quantum.ExecutionBroadcaster.handle_event/2
 web.1  | Last message: {:"$gen_producer", {#PID<0.511.0>, #Reference<0.883393263.365690881.197763>}, {:ask, 1000}}

My test config looks something like this:

config :violeta, Violeta.Scheduler,
  jobs: [
    test: [
      schedule: "* * * * *",
      task: {
        Violeta.Pigeon,
        :test,
        [%{
          from: "15555555555",
          to: "15555555555",
          message: "Testing the scheduler."
        }]
      }
    ]

Any thoughts?