artists: fix deadlock when banning artists.
Caused by d854bf6b. Banning an artist would deadlock because it was
performed in a transaction, which didn't work with the `parallel_each`
inside the "create an implication to banned_artist" step.
This commit is contained in:
@@ -169,6 +169,9 @@ class ApplicationRecord < ActiveRecord::Base
|
|||||||
concerning :ConcurrencyMethods do
|
concerning :ConcurrencyMethods do
|
||||||
class_methods do
|
class_methods do
|
||||||
def parallel_each(batch_size: 1000, in_processes: 4, in_threads: nil, &block)
|
def parallel_each(batch_size: 1000, in_processes: 4, in_threads: nil, &block)
|
||||||
|
# XXX We may deadlock if a transaction is open; do a non-parallel each.
|
||||||
|
return find_each(&block) if connection.transaction_open?
|
||||||
|
|
||||||
# XXX Use threads in testing because processes can't see each other's
|
# XXX Use threads in testing because processes can't see each other's
|
||||||
# database transactions.
|
# database transactions.
|
||||||
if Rails.env.test?
|
if Rails.env.test?
|
||||||
@@ -176,9 +179,6 @@ class ApplicationRecord < ActiveRecord::Base
|
|||||||
in_threads = 2
|
in_threads = 2
|
||||||
end
|
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_user = CurrentUser.user
|
||||||
current_ip = CurrentUser.ip_addr
|
current_ip = CurrentUser.ip_addr
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user