From d082c47618bdf6f6436a4ce30a29c8228cbacde0 Mon Sep 17 00:00:00 2001 From: Keenan Brock Date: Mon, 17 Jul 2017 14:40:13 -0400 Subject: [PATCH] Add $SEEDING_LOCK_TIMEOUT for high latency seeding 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 --- lib/evm_database.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/evm_database.rb b/lib/evm_database.rb index 59b44822543..6c6f1751c67 100644 --- a/lib/evm_database.rb +++ b/lib/evm_database.rb @@ -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) @@ -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