-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Introduce new ActiveRecord transaction error classes #25107
Introduce new ActiveRecord transaction error classes #25107
Conversation
r? @arthurnn (@rails-bot has picked a reviewer for you, use r? to override) |
r? @jeremy |
Also did a quick check and it seems like the MS SQL Server adapter is only translating deadlock errors - which is also @jeremy Your thoughts? Can we proceed with this current set of changes? |
d8bbacd
to
f5c0c7f
Compare
Just wanted to ask. Any feedback on this? |
Perfect investigation. Thank you so much. |
…r-classes Introduce new ActiveRecord transaction error classes Closes #26018
If the deadlock has occurred `ActiveRecord::Deadlocked` will raise. Ref: rails#25107, rails#26059
If the deadlock has occurred `ActiveRecord::Deadlocked` will raise. Ref: rails#25107, rails#26059
`ActiveRecord::TransactionSerializationError` was introduces in rails#25093. However, refactored in rails#25107, `TransactionSerializationError` is gone.
Summary
This is a WIP follow-up to #25093.
I went ahead with @jeremy's recommendation of introducing
ActiveRecord::TransactionRollbackError
, with subclasses to distinguish between a serialization failure or deadlock.Checked around, and it looks like MySQL is just returning an
Error: 1213 SQLSTATE: 40001
, whereas PostgreSQL tries to distinguish between serialization failures and deadlocks. Given the following test scenarios:PostgreSQL returns
40001
for the first scenario and40P01
for the second. MySQL returns40001
for both.Also checked MS SQL Server and Oracle and - like MySQL - they only have error mappings for
40001
, which they use for serialization failures.Other Information:
PostgreSQL: http://www.postgresql.org/docs/devel/static/errcodes-appendix.html
MySQL 5.7: https://dev.mysql.com/doc/refman/5.7/en/error-messages-server.html
MS SQL Server: https://msdn.microsoft.com/en-us/library/ms714687.aspx
Oracle Database 12c: https://docs.oracle.com/database/121/ZZMOD/appd.htm#ZZMOD338