Skip to content
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

Error class revamp (part 2) #143

Merged
merged 5 commits into from
Jan 23, 2024
Merged

Error class revamp (part 2) #143

merged 5 commits into from
Jan 23, 2024

Conversation

jhawthorn
Copy link
Member

@jhawthorn jhawthorn commented Dec 21, 2023

@composerinteralia and I paired on making another pass over the errors. Partly inspired by complexities revealed in rails/rails#50202

The most significant change is that this redefines === on our custom SystemCallError descendants to use the standard Module#=== implementation. Without this they are hard to check for specifically because the Errno classes redefine === to make anything which responds to errno and returns the same one equal. As suggested by @byroot in rails/rails#50202 (comment)

This also removes the inheritance of Trilogy::TimeoutError from Errno::ETIMEDOUT, as that represents a timeout we have declared after waiting rather than an I/O timeout the kernel/stdlib is informing us about.

Lastly this deprecates Trilogy::ConnectionRefusedError and Trilogy::ConnectionResetError, replacing them with Trilogy::SyscallError::ECONNREFUSED and Trilogy::SyscallError::ECONNRESET (and making them aliases). This avoids having duplicate errors representing the same thing and makes all our "errno" errors share common implementation 😌. As a bonus this removes some C and replaces it with Ruby.

I think this makes some good progress in making errors easier to handle, but I do anticipate making at least a "part 3" 😅.

cc @adrianna-chang-shopify @matthewd

jhawthorn and others added 5 commits December 18, 2023 13:11
Co-authored-by: Daniel Colson <composerinteralia@github.com>
Co-authored-by: Daniel Colson <composerinteralia@github.com>
Co-authored-by: Daniel Colson <composerinteralia@github.com>
Without this Trilogy::SyscallError::* matches all matching instances of
::Errno::*, which makes the subclass useless in differentiating.

Co-authored-by: Daniel Colson <composerinteralia@github.com>
This should be its own error class, it does not come from an ETIMEDOUT,
and inheriting from that makes this class hard to differentiate.

Co-authored-by: Daniel Colson <composerinteralia@github.com>
Copy link
Collaborator

@adrianna-chang-shopify adrianna-chang-shopify left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

@composerinteralia composerinteralia merged commit 901dafe into main Jan 23, 2024
15 checks passed
@composerinteralia composerinteralia deleted the error_class_revamp2 branch January 23, 2024 20:15
composerinteralia added a commit to composerinteralia/rails that referenced this pull request Jan 23, 2024
At GitHub we get a fair number of Trilogy `ETIMEDOUT` errors (for known
reasons that we might be able to improve somewhat, but I doubt we'll
make them go away entirely). These are very much retryable network
errors, so it'd be handy if these `ETIMEDOUT` errors were translated to
`ConnectionFailed` instead of `StatementInvalid`, making them
`retryable_connection_error`s.

https://github.com/rails/rails/blob/ed2bc92b82ddc111150cdf48bb646fd97b3baacb/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb#L1077

We're already translating `ECONNRESET` (via matching on the error
message) and `EPIPE` to `ConnectionFailed`. Rather than adding another
case, this commit treats all of the Trilogy `SystemCallError` subclasses
as `ConnectionFailed`.

This requires bumping trilogy 2.7 so we can get
trilogy-libraries/trilogy#143
composerinteralia added a commit to composerinteralia/rails that referenced this pull request Jan 23, 2024
At GitHub we get a fair number of Trilogy `ETIMEDOUT` errors (for known
reasons that we might be able to improve somewhat, but I doubt we'll
make them go away entirely). These are very much retryable network
errors, so it'd be handy if these `ETIMEDOUT` errors were translated to
`ConnectionFailed` instead of `StatementInvalid`, making them
`retryable_connection_error`s.

https://github.com/rails/rails/blob/ed2bc92b82ddc111150cdf48bb646fd97b3baacb/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb#L1077

We're already translating `ECONNRESET` (via matching on the error
message) and `EPIPE` to `ConnectionFailed`. Rather than adding another
case, this commit treats all of the Trilogy `SystemCallError` subclasses
as `ConnectionFailed`.

This requires bumping trilogy 2.7 so we can get
trilogy-libraries/trilogy#143
viralpraxis pushed a commit to viralpraxis/rails that referenced this pull request Mar 24, 2024
At GitHub we get a fair number of Trilogy `ETIMEDOUT` errors (for known
reasons that we might be able to improve somewhat, but I doubt we'll
make them go away entirely). These are very much retryable network
errors, so it'd be handy if these `ETIMEDOUT` errors were translated to
`ConnectionFailed` instead of `StatementInvalid`, making them
`retryable_connection_error`s.

https://github.com/rails/rails/blob/ed2bc92b82ddc111150cdf48bb646fd97b3baacb/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb#L1077

We're already translating `ECONNRESET` (via matching on the error
message) and `EPIPE` to `ConnectionFailed`. Rather than adding another
case, this commit treats all of the Trilogy `SystemCallError` subclasses
as `ConnectionFailed`.

This requires bumping trilogy 2.7 so we can get
trilogy-libraries/trilogy#143
fractaledmind pushed a commit to fractaledmind/rails that referenced this pull request May 13, 2024
At GitHub we get a fair number of Trilogy `ETIMEDOUT` errors (for known
reasons that we might be able to improve somewhat, but I doubt we'll
make them go away entirely). These are very much retryable network
errors, so it'd be handy if these `ETIMEDOUT` errors were translated to
`ConnectionFailed` instead of `StatementInvalid`, making them
`retryable_connection_error`s.

https://github.com/rails/rails/blob/ed2bc92b82ddc111150cdf48bb646fd97b3baacb/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb#L1077

We're already translating `ECONNRESET` (via matching on the error
message) and `EPIPE` to `ConnectionFailed`. Rather than adding another
case, this commit treats all of the Trilogy `SystemCallError` subclasses
as `ConnectionFailed`.

This requires bumping trilogy 2.7 so we can get
trilogy-libraries/trilogy#143
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants