FIX: Use a mutex when reseting column information while seeding.

`rake multisite:migrate` runs SeedFu concurently in threads so we need
this to be thread safe.
This commit is contained in:
Guo Xiang Tan 2020-06-23 09:15:29 +08:00
parent 0384b6d910
commit d775338d63
No known key found for this signature in database
GPG Key ID: FBD110179AAC1F20
1 changed files with 12 additions and 7 deletions

View File

@ -1,9 +1,13 @@
# frozen_string_literal: true
class SeedData::Refresher
@mutex = Mutex.new
def self.refresh!
return if @refreshed
@mutex.synchronize do
return if @refreshed
# Fix any bust caches post initial migration
# Not that reset_column_information is not thread safe so we have to becareful
# not to run it concurrently within the same process.
@ -13,6 +17,7 @@ class SeedData::Refresher
@refreshed = true
end
end
end
SeedData::Refresher.refresh!