diff --git a/integration_test/cases/transaction_test.exs b/integration_test/cases/transaction_test.exs index ab3adf17..bc8cdabb 100644 --- a/integration_test/cases/transaction_test.exs +++ b/integration_test/cases/transaction_test.exs @@ -1187,6 +1187,37 @@ defmodule TransactionTest do ] = A.record(agent) end + test "status disconnect_and_retry succeeds" do + err = RuntimeError.exception("oops") + + stack = [ + {:ok, :state}, + {:disconnect_and_retry, err, :new_state}, + :ok, + fn opts -> + send(opts[:parent], :reconnected) + {:ok, :reconnected_state} + end, + {:idle, :newest_state} + ] + + {:ok, agent} = A.start_link(stack) + + opts = [agent: agent, parent: self()] + {:ok, pool} = P.start_link(opts) + + assert P.status(pool, opts) == :idle + assert_receive :reconnected + + assert [ + connect: [_], + handle_status: [_, :state], + disconnect: [^err, :new_state], + connect: [_], + handle_status: [_, :reconnected_state] + ] = A.record(agent) + end + test "status returns result on successful run" do stack = [ {:ok, :state}, diff --git a/lib/db_connection.ex b/lib/db_connection.ex index b9716019..be0be430 100644 --- a/lib/db_connection.ex +++ b/lib/db_connection.ex @@ -1924,6 +1924,7 @@ defmodule DBConnection do other -> case retry_or_handle_common_result(other, conn, meter) do + {:retry, _, _} = retry -> retry {:error, _, meter} -> {:ok, :error, meter} {kind, reason, stack, _meter} -> :erlang.raise(kind, reason, stack) _ -> other