DateTime issue with Elixir Oban

Hello, I recently started working on a project in Elixir. I was trying to set up Job processing using Oban.
Everything is working fine except that whenever the queue fails and retries it throws a DateTime error. Sharing the stack trace below.

Please let me know if anybody has any thoughts on this

[error] Task Oban.Queue.BSP.Producer started from #PID<0.1186.0> terminating ** (FunctionClauseError) no function clause matching in DateTime.add/4 (elixir 1.10.3) lib/calendar/datetime.ex:1047: DateTime.add(-U[2020-06-01 09:11:22.192537Z], 8 0.0, :second, Calendar.UTCOnlyTimeZoneDatabase) (oban 1.2.0) lib/oban/query.ex:207: Oban.Query.retry_job/6 (oban 1.2.0) lib/oban/queue/executor.ex:102: Oban.Queue.Executor.report_failure/6

(elixir 1.10.3) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2 (elixir 1.10.3) lib/task/supervised.ex:35: Task.Supervised.reply/5 (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3

Function: &Oban.Queue.Executor.cal1/2 Args: [%Oban.JobI__meta__: #Ecto.Schema.Metadata<:loaded, “public”, “oban_jobs”>, args: %{“mes sage” => %{“flow” => “outbound”, “id” => 9, “recipient_id” => 6, “sender_id” => 1, “type” => "text ", “wa_status” => “delivered”}, “payload” => %{“channel” => “whatsapp”, “destination” => “91991744 3994”, “message” => “I"text”:“Hii”,“type”:“text"1”, “source” => “917834811114”, “” => “Default Contact”}}, attempt: 1, attempted_at: -U[2020-06-01 09:09:35.710697Z], attempted_by: [“Pankajs—MacBook—Pro-3”, “bsp”, “1j7507q6”], completed_at: nil, discarded_at: nil, errors: [] , id: 5, inserted_at: —U[2020-06-01 09:09:35.704421Z], max_attempts: 3, priority: 0, queue: “gupsh up”, scheduled_at: —U[2020-06-01 09:09:35.704421Z], state: “executing”, tags: [], unique: nil, wor ker: “TwoWay.Communications.BSP.Worker”}, %Oban.Config{beats_maxage: 300, circuit_backoff: 30000, crontab: [], dispatch_cooldown: 5, name: Oban, node: “Pankajs—MacBook—Pro-3”, poll_interva a 1: 1000, prefix: “public”, prune: {:maxlen, 100001, prune_interval: 60000, prune_limit: 5000, queu es: [default: 10, bsp: 10, webhook: 10], repo: TwoWay.Repo, rescue_after: 60, rescue_interval: 60000, shutdown_grace_period: 15000, timezone: “Etc/UTC”, verbose: false}]

1 Like

The second argument there appears to be the issue - DateTime.add expects an integer, not a floating-point number. That value comes from the backoff/1 callback defined on the job - the typespec is pos_integer -> pos_integer, but the examples in the documentation sometimes return a floating-point.

I’ve submitted a PR to adjust the examples; if you’re using a custom backoff/1 function, check what type it is returning.


@al2o3cr thank you so much for the quick response and fixing this issue.

1 Like