Skip to content

Commit

Permalink
Only call check_for_timeout on messages that are likely timedout
Browse files Browse the repository at this point in the history
This prevents us from bringing back every message in dequeue in the
region to just check its timeout values when we could do the check
in sql
  • Loading branch information
carbonin committed Dec 10, 2019
1 parent 0c8fa8d commit 4c674bf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/miq_queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ def check_for_timeout(log_prefix = "MIQ(MiqQueue.check_for_timeout)", grace = 10
end

def self.check_for_timeout
where(:state => STATE_DEQUEUE).find_each(&:check_for_timeout)
where(:state => STATE_DEQUEUE).where("(select date_part('epoch', updated_on) + msg_timeout) < ?", Time.now.to_i).each(&:check_for_timeout)
end

def finished?
Expand Down

0 comments on commit 4c674bf

Please sign in to comment.