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

[ActiveRecord] Superclass for aborted queries #36694

Merged
merged 1 commit into from Jul 16, 2019

Conversation

@kirs
Copy link
Member

@kirs kirs commented Jul 16, 2019

These days, when developer wants to rescue all possible timeouts (but not other query exceptions), they have to do rescue ActiveRecord::QueryCancelled, ActiveRecord::StatementTimeout, ActiveRecord::AdapterTimeout. It's too easy to miss one and don't rescue what you expected.

I'd like to introduce a single super class for all timeout errors to make it easy for developers to do rescue ActiveRecord::QueryAborted.

cc @casperisfine @rafaelfranca @Edouard-chin @bryanparadis

activerecord/lib/active_record/errors.rb Outdated Show resolved Hide resolved
Loading
@@ -353,20 +353,24 @@ class Deadlocked < TransactionRollbackError
class IrreversibleOrderError < ActiveRecordError
end

# Superclass for all timeout-related errors
class Timeout < StatementInvalid
Copy link
Member

@Edouard-chin Edouard-chin Jul 16, 2019

Choose a reason for hiding this comment

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

Does it make sense that Timeout still inherits from StatementInvalid? It was previously like this for backward compatibility reasons , but does it still apply now ? cc/ @byroot

Loading

Copy link
Member

@rafaelfranca rafaelfranca Jul 16, 2019

Choose a reason for hiding this comment

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

Yes. We still need to keep it backward compatible.

Loading

activerecord/lib/active_record/errors.rb Outdated Show resolved Hide resolved
Loading
activerecord/lib/active_record/errors.rb Outdated Show resolved Hide resolved
Loading
activerecord/lib/active_record/errors.rb Outdated Show resolved Hide resolved
Loading
@kirs kirs force-pushed the timeout-error-superclass branch from 71fd438 to 9866497 Jul 16, 2019
@kirs kirs force-pushed the timeout-error-superclass branch from 9866497 to 730d810 Jul 16, 2019
@kirs kirs changed the title [ActiveRecord] Superclass for timeout errors [ActiveRecord] Superclass for aborted queries Jul 16, 2019
@kirs
Copy link
Member Author

@kirs kirs commented Jul 16, 2019

@rafaelfranca thanks for feedback, updated!

Loading

@rafaelfranca rafaelfranca merged commit 1b984fc into rails:master Jul 16, 2019
2 checks passed
Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants