Add Repo name to timeout errors

Open
#346 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
55/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Quiet
Tech stack
elixir
Domain
database

Research direction

Start with PR 332 and the supplied DbConnectionErrorTest reproduction. Run the two ExUnit cases to compare timeout and ownership errors, then document the difference and the missing Repo name without assuming a timeout implementation change. Done means the reproduction and observed behavior are recorded clearly.

Written by the indexing model from the issue text.

Description

In https://github.com/elixir-ecto/db_connection/pull/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
Dominant language
Elixir
Stars
355
Forks
122
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from elixir-ecto/db_connection

All issues in elixir-ecto/db_connection

Similar issues

More Elixir issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.