Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions integration_test/cases/transaction_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
1 change: 1 addition & 0 deletions lib/db_connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading