tests: fix deadlock during artist ban test.
The artist ban tests deadlocked because of a weird interaction between threads and database transactions when tagging posts in parallel. Add a hack to work around it.
This commit is contained in:
@@ -168,7 +168,7 @@ class ApplicationRecord < ActiveRecord::Base
|
||||
|
||||
concerning :ConcurrencyMethods do
|
||||
class_methods do
|
||||
def parallel_each(batch_size: 1000, in_processes: 4, in_threads: nil)
|
||||
def parallel_each(batch_size: 1000, in_processes: 4, in_threads: nil, &block)
|
||||
# XXX Use threads in testing because processes can't see each other's
|
||||
# database transactions.
|
||||
if Rails.env.test?
|
||||
@@ -176,6 +176,9 @@ class ApplicationRecord < ActiveRecord::Base
|
||||
in_threads = 2
|
||||
end
|
||||
|
||||
# XXX Threads deadlock during tests if a transaction is open; do a non-parallel each.
|
||||
return find_each(&block) if Rails.env.test? && connection.transaction_open?
|
||||
|
||||
current_user = CurrentUser.user
|
||||
current_ip = CurrentUser.ip_addr
|
||||
|
||||
|
||||
Reference in New Issue
Block a user