aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2017-11-13 20:15:16 +0900
committerGitHub <noreply@github.com>2017-11-13 20:15:16 +0900
commita968a7609db56f56298c462aa26809588f9375de (patch)
tree22974df0152e26740348819760a2e011562440af /activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
parent479f17dc11287cf46b4707b6a8caebef2875a817 (diff)
downloadrails-a968a7609db56f56298c462aa26809588f9375de.tar.gz
rails-a968a7609db56f56298c462aa26809588f9375de.tar.bz2
rails-a968a7609db56f56298c462aa26809588f9375de.zip
Add new error class `StatementTimeout` which will be raised when statement timeout exceeded (#31129)
We are sometimes using The MAX_EXECUTION_TIME hint for MySQL depending on the situation. It will prevent catastrophic performance down by wrong performing queries. The new error class `StatementTimeout` will make to be easier to handle that case. https://dev.mysql.com/doc/refman/5.7/en/optimizer-hints.html#optimizer-hints-execution-time
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb3
1 files changed, 3 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 bfec6fb784..ca651ef390 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
@@ -635,6 +635,7 @@ module ActiveRecord
ER_CANNOT_ADD_FOREIGN = 1215
ER_CANNOT_CREATE_TABLE = 1005
ER_LOCK_WAIT_TIMEOUT = 1205
+ ER_QUERY_TIMEOUT = 3024
def translate_exception(exception, message)
case error_number(exception)
@@ -660,6 +661,8 @@ module ActiveRecord
Deadlocked.new(message)
when ER_LOCK_WAIT_TIMEOUT
TransactionTimeout.new(message)
+ when ER_QUERY_TIMEOUT
+ StatementTimeout.new(message)
else
super
end