From 4ca452a2c45ed4149a85ee28a65c3436068d42ad Mon Sep 17 00:00:00 2001 From: Parker Selbert Date: Fri, 19 Jan 2024 08:52:55 -0600 Subject: [PATCH] Rescue and report staging errors with telemetry Staging errors from queue contention or other database issues would cause the top level stager process to crash. Eventually that could shut down the entire Oban supervision tree. Now we rescue standard database connectivity issues instead and report them as errors in telemetry. --- lib/oban/stager.ex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/oban/stager.ex b/lib/oban/stager.ex index 38078b7b..fcc7ca31 100644 --- a/lib/oban/stager.ex +++ b/lib/oban/stager.ex @@ -135,6 +135,8 @@ defmodule Oban.Stager do %{staged_count: length(staged), staged_jobs: staged} end) + rescue + error in [DBConnection.ConnectionError, Postgrex.Error] -> {:error, error} end defp stage_scheduled(state, leader?: true) do