oban-bg / oban

💎 Robust job processing in Elixir, backed by modern PostgreSQL and SQLite3
https://oban.pro
Apache License 2.0
3.28k stars 308 forks source link

"Handler "oban.batch" has failed and has been detached" when job is cancelled via oban web #1094

Closed kafaichoi closed 4 months ago

kafaichoi commented 4 months ago

Precheck

Environment

Current Behavior

The following error occur when a job is being cancelled(from executing state) via oban web

17:03:40.564 line=172 pid=<0.3315.0> file=/X/deps/telemetry/src/telemetry.erl mfa=:telemetry.execute/3 [error] Handler "oban.batch" has failed and has been detached. Class=:error
Reason={:badkey, :meta, %{id: 766, state: "executing", queue: "default"}}
Stacktrace=[
  {Oban.Pro.Batcher, :"-handle_event/4-fun-0-", 2,
   [file: ~c"lib/oban/pro/batcher.ex", line: 46]},
  {Enum, :"-each/2-lists^foreach/1-0-", 2, [file: ~c"lib/enum.ex", line: 987]},
  {:telemetry, :"-execute/3-fun-0-", 4,
   [
     file: ~c"/X/deps/telemetry/src/telemetry.erl",
     line: 160
   ]},
  {:lists, :foreach_1, 2, [file: ~c"lists.erl", line: 1686]},
  {:telemetry, :span, 3,
   [
     file: ~c"/X/deps/telemetry/src/telemetry.erl",
     line: 324
   ]},
  {Oban, :cancel_all_jobs, 2, [file: ~c"lib/oban.ex", line: 1285]},
  {Oban, :cancel_job, 2, [file: ~c"lib/oban.ex", line: 1254]},
  {Oban.Web.Telemetry, :"-action/4-fun-0-", 2,
   [file: ~c"lib/oban/web/telemetry.ex", line: 147]},
  {:telemetry, :span, 3,
   [
     file: ~c"/X/deps/telemetry/src/telemetry.erl",
     line: 321
   ]},
  {Oban.Web.JobsPage, :handle_info, 2,
   [file: ~c"lib/oban/web/pages/jobs_page.ex", line: 197]},
  {Phoenix.LiveView.Channel, :handle_info, 2,
   [file: ~c"lib/phoenix_live_view/channel.ex", line: 359]},
  {:gen_server, :try_handle_info, 3, [file: ~c"gen_server.erl", line: 1095]},
  {:gen_server, :handle_msg, 6, [file: ~c"gen_server.erl", line: 1183]},
  {:proc_lib, :init_p_do_apply, 3, [file: ~c"proc_lib.erl", line: 241]}

Expected Behavior

There shouldn't be error.

More detail

The application running oban_web didn't start oban queue with queues: false. (We are having 2 elixir application. One is for core logic which start oban queue. another one is admin dashboard where oban_web is mounted)

Also no oban pro feature is being used yet(no batching)

sorentwo commented 4 months ago

This is because Oban isn't configured to use the Smart engine. The handler is fixed on main and it'll be in Pro v1.4.8, due out later today.

kafaichoi commented 4 months ago

Thank you. @sorentwo Since we are not using Oban.Pro.Batcher, I assume it's safe to not continue with this version without rolling back?

sorentwo commented 4 months ago

You don't need to roll anything back. If you're not using batches then that error won't impact anything. Switching to the Smart engine or removing oban_pro from your deps until you're ready to start using those features will fix it as well.