sorentwo/oban

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

Closed this issue · 3 comments

Precheck

  • Do a quick search and make sure the bug has not yet been reported
  • For support, favor using the Elixir Forum, Slack, IRC, etc.
  • Be friendly and polite!

Environment

  • Oban Version: oban: 2.17.0, oban_met: 0.1.6, oban_pro: 1.4.7, oban_web: 2.10.4
  • PostgreSQL Version: 15
  • Elixir & Erlang/OTP Versions (elixir --version) 1.16.1

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)

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.

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?

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.