aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorDoug Barth <doug@pagerduty.com>2013-11-05 10:04:00 -0800
committerDoug Barth <doug@pagerduty.com>2013-11-05 11:47:08 -0800
commit5d870c929157b7c7949c9356d4f88b97c8848ec3 (patch)
treeb9daf6484495a9c24fdd60fbe695068fb045d296 /activerecord/lib/active_record
parent44406d1e77061ce22effaae4698918c1f9f6271a (diff)
downloadrails-5d870c929157b7c7949c9356d4f88b97c8848ec3.tar.gz
rails-5d870c929157b7c7949c9356d4f88b97c8848ec3.tar.bz2
rails-5d870c929157b7c7949c9356d4f88b97c8848ec3.zip
Don't swallow exceptions in transctional statements
The MySQL connection adapater swallows all StandardError exceptions, which includes Mysql::Error and Mysql2::Error. The comment in the exception clause claims errors thrown here indicate that transactions aren't supported by the server but that isn't necessarily true. It's possible the MySQL server has gone away and swallowing a failed commit may let the application return a successful response when the data has not been saved. Also, replication libraries like Galera require that the application handle exceptions thrown at BEGIN/COMMIT. I'm unable to determine what version of MySQL threw an exception for transactional statements. I tried as far back as 3.23.49 with InnoDB disabled but BEGIN & COMMIT statements do not throw an error. If there's a real case for this logic to continue, we could instead push this behavior into a configuration setting. The exception swallowing has been there since the beginning: db045dbbf60b53dbe013ef25554fd013baf88134
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb8
-rw-r--r--activerecord/lib/active_record/connection_adapters/mysql_adapter.rb2
2 files changed, 0 insertions, 10 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 138ab811dc..9a88be5219 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
@@ -314,27 +314,19 @@ module ActiveRecord
def begin_db_transaction
execute "BEGIN"
- rescue
- # Transactions aren't supported
end
def begin_isolated_db_transaction(isolation)
execute "SET TRANSACTION ISOLATION LEVEL #{transaction_isolation_levels.fetch(isolation)}"
begin_db_transaction
- rescue
- # Transactions aren't supported
end
def commit_db_transaction #:nodoc:
execute "COMMIT"
- rescue
- # Transactions aren't supported
end
def rollback_db_transaction #:nodoc:
execute "ROLLBACK"
- rescue
- # Transactions aren't supported
end
# In the simple case, MySQL allows us to place JOINs directly into the UPDATE
diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
index 88c9494fc6..d61847506d 100644
--- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
@@ -468,8 +468,6 @@ module ActiveRecord
def begin_db_transaction #:nodoc:
exec_query "BEGIN"
- rescue Mysql::Error
- # Transactions aren't supported
end
private