Repository navigation
Include pool label in closed connection errors - #363
agustin2606 wants to merge 1 commit into
Conversation
|
@nathanl did we discuss this before as well? The concern with this approach is additional data copying into the holder on every operation. I wonder if this could be lifted from the process instead (or not because the process may be dead). |
|
the proxy is already dead by the time this error is built (ownership timeout stops it and the holder table goes with it), and the caller's pool_ref only points at that proxy, so there's no process it can reach to read the label from. two ways to avoid the per-operation copy: store the label under its own key in the holder and read it only on checkout (one extra ets lookup per checkout), or read it from the call opts in |
Fixes #346
When a pool is started with
:label(as ecto_sql does with the repo name since elixir-ecto/ecto_sql#698), the "connection is closed" error now says which pool it came from.Problem
With several repos, an ownership timeout in tests surfaces as an error that doesn't say which repo it belongs to.
Cause
The error is built in the caller by
DBConnection.Holderafter the ownership proxy has stopped and its holder table is gone, so there is no live process left whose label could be read (the approach #332 used forOwnershipError).Fix
:labelin the holder'sconnrecord when it checks in.Holder.checkoutalready reads that record, so it copies the label into thepool_ref. The ownership proxy passes the label of the connection it checked out on to its own holder.[inspect(label)]prefix, written withinspectlike the label in the ownership error (Ownership.Manager).:labelthe message is unchanged. No process labels are involved, so it works on every supported OTP version.Testing
label: TestRepo: the error message is prefixed with[TestRepo].