oban-bg/oban

Error log `no function clause matching` during server shutdown

Closed this issue ยท 1 comments

Hi there! Thanks for the amazing working on Oban ๐Ÿ™.

Here is a small bug report:

Environment

  • Oban Version: 2.13.2
  • PostgreSQL Version: 13.7
  • Elixir & Erlang/OTP Versions (elixir --version): 1.14.4 & 25.3.0

Current Behavior

During a shutdown of our servers, we receive the following error logs:

SIGTERM received - shutting down

GenServer {Oban.Registry, {Oban, {:plugin, Oban.Plugins.Pruner}}} terminating
** (FunctionClauseError) no function clause matching in Oban.Plugins.Pruner.handle_info/2
    (oban 2.13.2) lib/oban/plugins/pruner.ex:109: Oban.Plugins.Pruner.handle_info({:EXIT, #PID<0.1778.0>, :shutdown}, %Oban.Plugins.Pruner.State{conf: %Oban.Config{dispatch_cooldown: 5, engine: Oban.Engines.Basic, get_dynamic_repo: nil, log: false, name: Oban, node: "...", notifier: Oban.Notifiers.Postgres, peer: Oban.Peers.Postgres, plugins: [Oban.Plugins.Pruner, Oban.Plugins.Stager], prefix: "public", queues: [upload_processing: [limit: 5]], repo: UploadService.Repo, shutdown_grace_period: 15000, testing: :disabled}, name: {:via, Registry, {Oban.Registry, {Oban, {:plugin, Oban.Plugins.Pruner}}}}, timer: #Reference<0.1380755889.311951361.242224>, interval: 30000, max_age: 60, limit: 10000})
    (stdlib 4.3.1) gen_server.erl:1123: :gen_server.try_dispatch/4
    (stdlib 4.3.1) gen_server.erl:1200: :gen_server.handle_msg/6
    (stdlib 4.3.1) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
Last message: {:EXIT, #PID<0.1778.0>, :shutdown}

GenServer {Oban.Registry, {Oban, {:plugin, Oban.Plugins.Stager}}} terminating
** (FunctionClauseError) no function clause matching in Oban.Plugins.Stager.handle_info/2
    (oban 2.13.2) lib/oban/plugins/stager.ex:102: Oban.Plugins.Stager.handle_info({:EXIT, #PID<0.1778.0>, :shutdown}, %Oban.Plugins.Stager.State{conf: %Oban.Config{dispatch_cooldown: 5, engine: Oban.Engines.Basic, get_dynamic_repo: nil, log: false, name: Oban, node: "...", notifier: Oban.Notifiers.Postgres, peer: Oban.Peers.Postgres, plugins: [Oban.Plugins.Pruner, Oban.Plugins.Stager], prefix: "public", queues: [upload_processing: [limit: 5]], repo: UploadService.Repo, shutdown_grace_period: 15000, testing: :disabled}, name: {:via, Registry, {Oban.Registry, {Oban, {:plugin, Oban.Plugins.Stager}}}}, timer: #Reference<0.1380755889.311951361.242225>, limit: 5000, interval: 1000})
    (stdlib 4.3.1) gen_server.erl:1123: :gen_server.try_dispatch/4
    (stdlib 4.3.1) gen_server.erl:1200: :gen_server.handle_msg/6
    (stdlib 4.3.1) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
Last message: {:EXIT, #PID<0.1778.0>, :shutdown}

I don't think there are any direct consequences to it other than being noisy for our monitors.

Expected Behavior

During a clean shutdown, I wouldn't expect to see any errors logs.

That looks like an issue with your shutdown sequence. Something those plugins rely on, most likely your Repo, is shutting down before they do.

Be sure that Oban is toward the bottom of your supervision tree so it shuts down first. That will allow it to stop plugins and long-running jobs gracefully.