sorentwo/oban

`MatchError` on a DB transaction in `Oban.Peers.Postgres`

Closed this issue · 2 comments

Environment

  • main
  • 13.x
  • Elixir & Erlang/OTP Versions (elixir --version)
Erlang/OTP 26 [erts-14.0.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]

Elixir 1.16.0 (compiled with Erlang/OTP 24)

Current Behavior

We've seen this in Sentry:

** (MatchError) no match of right hand side value: {:error, :rollback}
  lib/oban/peers/postgres.ex in anonymous fn/2 in Oban.Peers.Postgres.handle_info/2 at line 93
  <redacted>/deps/telemetry/src/telemetry.erl in :telemetry.span/3 at line 321
  lib/oban/peers/postgres.ex in Oban.Peers.Postgres.handle_info/2 at line 92
  gen_server.erl in :gen_server.try_handle_info/3 at line 1077
  gen_server.erl in :gen_server.handle_msg/6 at line 1165
  proc_lib.erl in :proc_lib.init_p_do_apply/3 at line 241

This shows up in the current Oban code:

{:ok, state} =
Repo.transaction(state.conf, fn ->
state
|> delete_expired_peers()
|> upsert_peer()
end)

Expected Behavior

This transaction result should likely be handled, right?

Thanks for the report. A rollback is unexpected there, and we don't want it to crash the peer.

Thanks for the quick fix @sorentwo! 💟