In #332 we added the Repo's name (via a label) to ownership errors.
We didn't add it to timeout errors yet because it's more complex, but José expressed interest in doing it later - see comment thread.
For this issue, I just want to document the difference with a simple reproduction:
defmodule DbConnectionErrorTest do
use ExUnit.Case
alias MyApp.Repo
test "Unhandled case: trigger timeout error" do
Ecto.Adapters.SQL.Sandbox.checkout(Repo, ownership_timeout: 100)
Repo.transact(fn ->
Repo.query!("CREATE TEMP TABLE dogs (name text) ON COMMIT DROP")
# Hold the connection longer than the ownership_timeout above.
Process.sleep(200)
# Raises an exception that does not include the repo name
Repo.insert_all("dogs", [%{name: "Barkley"}])
{:ok, :ok}
end)
end
test "Handled case: trigger ownership error" do
# Raises an exception that includes the Repo name (as of PR 332)
spawn(fn ->
Process.sleep(1_000)
Repo.query!("SELECT 1")
end)
on_exit(fn -> Process.sleep(1500) end)
end
end
In #332 we added the Repo's name (via a label) to ownership errors.
We didn't add it to timeout errors yet because it's more complex, but José expressed interest in doing it later - see comment thread.
For this issue, I just want to document the difference with a simple reproduction: