diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2017-08-22 19:25:20 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-22 19:25:20 -0400 |
commit | 80ccfec0740a32fa3a8c0d52549e5b7c59db1a02 (patch) | |
tree | 0d5907ff0da6d3d0cd30a876e974ba840cb437e8 /activerecord/lib | |
parent | 03556079efb01836ef5a18ff60e9920550e0fdcf (diff) | |
parent | c5edd97721aeaa4ceaa11e66327842a0aba1fdf7 (diff) | |
download | rails-80ccfec0740a32fa3a8c0d52549e5b7c59db1a02.tar.gz rails-80ccfec0740a32fa3a8c0d52549e5b7c59db1a02.tar.bz2 rails-80ccfec0740a32fa3a8c0d52549e5b7c59db1a02.zip |
Merge pull request #30360 from gcourtemanche/transaction_timedout
Add TransactionTimeout for MySQL error code 1205
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | 3 | ||||
-rw-r--r-- | activerecord/lib/active_record/errors.rb | 5 |
2 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb index e647389514..46bc74b7a7 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -630,6 +630,7 @@ module ActiveRecord ER_LOCK_DEADLOCK = 1213 ER_CANNOT_ADD_FOREIGN = 1215 ER_CANNOT_CREATE_TABLE = 1005 + ER_LOCK_WAIT_TIMEOUT = 1205 def translate_exception(exception, message) case error_number(exception) @@ -653,6 +654,8 @@ module ActiveRecord NotNullViolation.new(message) when ER_LOCK_DEADLOCK Deadlocked.new(message) + when ER_LOCK_WAIT_TIMEOUT + TransactionTimeout.new(message) else super end diff --git a/activerecord/lib/active_record/errors.rb b/activerecord/lib/active_record/errors.rb index e790760292..9ef3316393 100644 --- a/activerecord/lib/active_record/errors.rb +++ b/activerecord/lib/active_record/errors.rb @@ -334,4 +334,9 @@ module ActiveRecord # +reverse_order+ to automatically reverse. class IrreversibleOrderError < ActiveRecordError end + + # TransactionTimeout will be raised when lock wait timeout expires. + # Wait time value is set by innodb_lock_wait_timeout. + class TransactionTimeout < StatementInvalid + end end |