Skip to content

Commit 410ad1c

Browse files
authored
Merge pull request rails#53861 from zzak/leaks
Try to fix various flakes in AR tests
2 parents 65a2b74 + 6bdff8b commit 410ad1c

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

activerecord/test/cases/adapters/abstract_mysql_adapter/nested_deadlock_test.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Sample < ActiveRecord::Base
4848
Sample.transaction(requires_new: true) do
4949
assert_current_transaction_is_savepoint_transaction
5050
s1.lock!
51-
barrier.wait
51+
barrier.wait(30)
5252
s2.update value: 1
5353
end
5454
end
@@ -60,7 +60,7 @@ class Sample < ActiveRecord::Base
6060
Sample.transaction(requires_new: true) do
6161
assert_current_transaction_is_savepoint_transaction
6262
s2.lock!
63-
barrier.wait
63+
barrier.wait(30)
6464
s1.update value: 2
6565
end
6666
end
@@ -91,7 +91,7 @@ class Sample < ActiveRecord::Base
9191
Sample.transaction(requires_new: true) do
9292
assert_current_transaction_is_savepoint_transaction
9393
s1.lock!
94-
barrier.wait
94+
barrier.wait(30)
9595
s2.update value: 4
9696

9797
rescue ActiveRecord::Deadlocked
@@ -113,7 +113,7 @@ class Sample < ActiveRecord::Base
113113
Sample.transaction(requires_new: true) do
114114
assert_current_transaction_is_savepoint_transaction
115115
s2.lock!
116-
barrier.wait
116+
barrier.wait(30)
117117
s1.update value: 3
118118
rescue ActiveRecord::Deadlocked
119119
deadlocks += 1
@@ -143,7 +143,7 @@ class Sample < ActiveRecord::Base
143143
Sample.transaction(requires_new: true) do
144144
assert_current_transaction_is_savepoint_transaction
145145
s1.lock!
146-
barrier.wait
146+
barrier.wait(30)
147147
s2.update value: 4
148148
end
149149
rescue ActiveRecord::Deadlocked
@@ -160,7 +160,7 @@ class Sample < ActiveRecord::Base
160160
Sample.transaction(requires_new: true) do
161161
assert_current_transaction_is_savepoint_transaction
162162
s2.lock!
163-
barrier.wait
163+
barrier.wait(30)
164164
s1.update value: 3
165165
end
166166
rescue ActiveRecord::Deadlocked

activerecord/test/cases/encryption/concurrency_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ class ActiveRecord::Encryption::ConcurrencyTest < ActiveRecord::EncryptionTestCa
99
end
1010

1111
test "models can be encrypted and decrypted in different threads concurrently" do
12-
4.times.collect { |index| thread_encrypting_and_decrypting("thread #{index}") }.each(&:join)
12+
3.times.collect { |index| thread_encrypting_and_decrypting("thread #{index}") }.each(&:join)
1313
end
1414

1515
def thread_encrypting_and_decrypting(thread_label)
16-
EncryptedPost.insert_all 100.times.collect { |index| { title: "Article #{index} (#{thread_label})", body: "Body #{index} (#{thread_label})" } }
17-
posts = EncryptedPost.last(100)
16+
EncryptedPost.insert_all 10.times.collect { |index| { title: "Article #{index} (#{thread_label})", body: "Body #{index} (#{thread_label})" } }
17+
posts = EncryptedPost.last(10)
1818

1919
Thread.new do
2020
posts.each.with_index do |article, index|

0 commit comments

Comments
 (0)