Skip to content

Commit

Permalink
Add $SEEDING_LOCK_TIMEOUT for high latency seeding
Browse files Browse the repository at this point in the history
Seeding over a WAN can take longer than 10 minutes.
This allows the timeout to be increased temporarily.

https://bugzilla.redhat.com/show_bug.cgi?id=1422671
  • Loading branch information
kbrock committed Aug 1, 2017
1 parent 73c1993 commit d082c47
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/evm_database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@ def self.seed(classes = nil, exclude_list = [])
classes ||= PRIMORDIAL_CLASSES + (seedable_model_class_names - PRIMORDIAL_CLASSES)
classes -= exclude_list

lock_timeout = (ENV["SEEDING_LOCK_TIMEOUT"].presence || 10.minutes).to_i
# Only 1 machine can go through this at a time
# Populating the DB takes 20 seconds
# Not populating the db takes 3 seconds
MiqDatabase.with_lock(10.minutes) do
MiqDatabase.with_lock(lock_timeout) do
classes.each do |klass|
begin
klass = klass.constantize if klass.kind_of?(String)
Expand All @@ -90,6 +89,9 @@ def self.seed(classes = nil, exclude_list = [])
end

_log.info("Seeding... Complete")
rescue Timeout::Error
_log.error("Timed out seeding database (#{lock_timeout} seconds).")
raise
end

def self.host
Expand Down

0 comments on commit d082c47

Please sign in to comment.