-
Notifications
You must be signed in to change notification settings - Fork 115
Add label (repo name) to ownership and connection errors #332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| using mode #{inspect(mode)}. | ||
| using mode #{inspect(mode)} on repo #{inspect(repo)}. | ||
| (Note that a connection's mode reverts to :manual if its owner | ||
| terminates.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on line 381
|
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? |
| ets: ets, | ||
| log: log | ||
| log: log, | ||
| label: pool_opts[:label] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are passing the label, wouldn't make more sense to use it for Process.set_label? And then we don't. need to pass it around? It just becomes part of our Util.inspect_pid ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure the repo name would be a good label for the ownership manager - it isn't the repo per se, and probably ecto_sql and other callers shouldn't tell it how to label itself. I'm just trying to have this info available for the not_found error for this connection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could compose it {__MODULE__, label}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@josevalim I updated to set the process label. However, to get the repo name in the errors in DBConnection.Holder we have to pass them along, and I thought fetching the label back out of the process label was awkward. So I'm also putting it in to process state. Thoughts?
2665095 to
d949d5d
Compare
d949d5d to
a9ea94f
Compare
A label like MyApp.Repo can be passed via the :label option. It will be used in the process label for the DBConnection.Ownership.Manager process and will appear in error messages from both DBConnection.Ownership.Manager and DBConnection.Holder. This is helpful when applications use multiple repos (e.g., read replicas). Before: (DBConnection.OwnershipError) cannot find ownership process for #PID<...> (DBConnection.ConnectionError) connection is closed because of an error... After: (DBConnection.OwnershipError) cannot find ownership process for #PID<...> (MyApp.Repo) using mode :manual. (DBConnection.ConnectionError) MyApp.Repo connection is closed because of an error, disconnect or timeout 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.
a9ea94f to
4b3bb27
Compare
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 error messages from both
DBConnection.Ownership.ManagerandDBConnection.Holder. This is helpfulwhen 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.