diff options
author | Matthew Draper <matthew@trebex.net> | 2016-11-27 21:49:37 +1030 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2016-11-27 21:49:37 +1030 |
commit | c42daff32da8e75c684ba485df1d9e3868121ff3 (patch) | |
tree | a46738f4cfc7de971f460e48dfa6b17669695506 /activerecord | |
parent | 3050affc45fda105ecae4358e52059a8b231eed0 (diff) | |
download | rails-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.rb | 6 | ||||
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/transaction_test.rb | 8 |
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 |