aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2016-11-27 21:49:37 +1030
committerMatthew Draper <matthew@trebex.net>2016-11-27 21:49:37 +1030
commitc42daff32da8e75c684ba485df1d9e3868121ff3 (patch)
treea46738f4cfc7de971f460e48dfa6b17669695506 /activerecord
parent3050affc45fda105ecae4358e52059a8b231eed0 (diff)
downloadrails-c42daff32da8e75c684ba485df1d9e3868121ff3.tar.gz
rails-c42daff32da8e75c684ba485df1d9e3868121ff3.tar.bz2
rails-c42daff32da8e75c684ba485df1d9e3868121ff3.zip
abort_on_exception can't be disabled for a single thread
If it's enabled globally, it's on regardless of how individual threads are set.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/test/cases/adapters/mysql2/transaction_test.rb6
-rw-r--r--activerecord/test/cases/adapters/postgresql/transaction_test.rb8
2 files changed, 8 insertions, 6 deletions
diff --git a/activerecord/test/cases/adapters/mysql2/transaction_test.rb b/activerecord/test/cases/adapters/mysql2/transaction_test.rb
index b37abd7e2e..16101e38cb 100644
--- a/activerecord/test/cases/adapters/mysql2/transaction_test.rb
+++ b/activerecord/test/cases/adapters/mysql2/transaction_test.rb
@@ -10,6 +10,8 @@ module ActiveRecord
end
setup do
+ @abort, Thread.abort_on_exception = Thread.abort_on_exception, false
+
@connection = ActiveRecord::Base.connection
@connection.clear_cache!
@@ -25,6 +27,8 @@ module ActiveRecord
teardown do
@connection.drop_table "samples", if_exists: true
+
+ Thread.abort_on_exception = @abort
end
test "raises Deadlocked when a deadlock is encountered" do
@@ -35,8 +39,6 @@ module ActiveRecord
s2 = Sample.create value: 2
thread = Thread.new do
- Thread.current.abort_on_exception = false
-
Sample.transaction do
s1.lock!
barrier.wait
diff --git a/activerecord/test/cases/adapters/postgresql/transaction_test.rb b/activerecord/test/cases/adapters/postgresql/transaction_test.rb
index 372af6b2be..f130e344c4 100644
--- a/activerecord/test/cases/adapters/postgresql/transaction_test.rb
+++ b/activerecord/test/cases/adapters/postgresql/transaction_test.rb
@@ -11,6 +11,8 @@ module ActiveRecord
end
setup do
+ @abort, Thread.abort_on_exception = Thread.abort_on_exception, false
+
@connection = ActiveRecord::Base.connection
@connection.transaction do
@@ -25,6 +27,8 @@ module ActiveRecord
teardown do
@connection.drop_table "samples", if_exists: true
+
+ Thread.abort_on_exception = @abort
end
test "raises SerializationFailure when a serialization failure occurs" do
@@ -33,8 +37,6 @@ module ActiveRecord
after = Concurrent::CyclicBarrier.new(2)
thread = Thread.new do
- Thread.current.abort_on_exception = false
-
with_warning_suppression do
Sample.transaction isolation: :serializable do
before.wait
@@ -67,8 +69,6 @@ module ActiveRecord
s2 = Sample.create value: 2
thread = Thread.new do
- Thread.current.abort_on_exception = false
-
Sample.transaction do
s1.lock!
barrier.wait