diff --git a/app/models/miq_queue.rb b/app/models/miq_queue.rb index 2372ca51b0d..2bb37a74d3f 100644 --- a/app/models/miq_queue.rb +++ b/app/models/miq_queue.rb @@ -545,8 +545,12 @@ def check_for_timeout(log_prefix = "MIQ(MiqQueue.check_for_timeout)", grace = 10 end end + def self.candidates_for_timeout + where(:state => STATE_DEQUEUE).where("(select date_part('epoch', updated_on) + msg_timeout) < ?", Time.now.to_i) + end + def self.check_for_timeout - where(:state => STATE_DEQUEUE).where("(select date_part('epoch', updated_on) + msg_timeout) < ?", Time.now.to_i).each(&:check_for_timeout) + candidates_for_timeout.each(&:check_for_timeout) end def finished?