Add label (repo name) to ownership errors#332
Conversation
|
Hi @nathanl. I would prefer to not depend on repo, because it is really not a db_connection configuration or concern. Can you find anything on |
|
@josevalim good point, but won't 99% of users pass a repo? In |
|
@nathanl would you consider adding some libary-agnostic metadata(contained e.g. in a kw-list) to the exception a viable option? |
|
@realglebivanov Can you elaborate a bit on what that might look like? |
So, right now |
7b008da to
66bd0ec
Compare
66bd0ec to
2665095
Compare
|
Updated so that callers can optionally pass a 11:21:51.330 [error] Process #PID<0.1502.0> raised an exception
** (DBConnection.OwnershipError) cannot find ownership process for #PID<0.1502.0> (:erlang)
(GridPoint.Repo) using mode :manual.
(Note that a connection's mode reverts to :manual if its owner
terminates.) |
|
@josevalim what do you think of this approach? |
2665095 to
d949d5d
Compare
a9ea94f to
4b3bb27
Compare
|
I think this is ready for re-review. I'm disappearing until Jan 5, but if anything needs changing I'll take a look then. |
|
Sorry, this fell through the cracks. I would prefer to rely on the label given to the process name as much as possible, instead of passing the label around. Can we start with that? WDYT? |
|
Just wanted to add that I'm interested in this and happy to pick it up 🙂 |
4b3bb27 to
73da05b
Compare
|
Sorry for my long silence. Update coming soon. |
73da05b to
b42f944
Compare
When a `label` option (e.g., `label: MyApp.Repo`) is passed to
DBConnection, the Ownership Manager stores it as a process label.
When set, this is added to "cannot find ownership process" errors.
Before:
(DBConnection.OwnershipError) cannot find ownership process for
#PID<0.502.0> using mode :manual.
After:
(DBConnection.OwnershipError) cannot find ownership process for
#PID<0.502.0> (MyApp.Repo) using mode :manual.
b42f944 to
1827eb3
Compare
|
Updated to use only a process label. As you said @josevalim, using a process label alone doesn't let us put the repo name in something like (DBConnection.OwnershipError) cannot find ownership process for #PID<...>
(MyApp.Repo) using mode :manual.The related |
|
💚 💙 💜 💛 ❤️ |
A label like
MyApp.Repocan be passed via the:label option. It will beused in the process label for the
DBConnection.Ownership.Managerprocessand will appear in some error messages. This is helpful
when applications use multiple repos (e.g., read replicas).
Before:
After:
Tests verify labels appear correctly in both error types, and that errors
work correctly if no label is given.
In elixir-ecto/ecto_sql#698 the adapter is
updated to pass the repo name as a label.