Skip to content

Commit

Permalink
Merge pull request #8 from HusseinElMotayam/patch-1
Browse files Browse the repository at this point in the history
Extra disappeared check to avoid false-positives #7
  • Loading branch information
twonegatives authored Jan 23, 2018
2 parents 9e50962 + 6a27199 commit 1558c7c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/attentive_sidekiq/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ def update_disappeared_jobs
suspicious = AttentiveSidekiq::Suspicious.jobs
active_ids = AttentiveSidekiq::Active.job_ids
those_lost = suspicious.delete_if{|i| active_ids.include?(i["jid"])}

# Sidekiq might have been too fast finishing up a job that appeared in the suspicious list
# but didn't make it to the active list, so that's a false-positive.
# We need to get the new suspicious list again, and remove any lost jobs that are no longer there.
# Those jobs that appeared in the first suspicious list, but not the second one were simply finished
# quickly by Sidekiq before showing up as active by a worker.
suspicious = AttentiveSidekiq::Suspicious.jobs
those_lost.delete_if{|i| !suspicious.any?{|j| i['jid'] == j['jid']} }

those_lost.each do |job|
Disappeared.add(job)
Suspicious.remove(job['jid'])
Expand Down

0 comments on commit 1558c7c

Please sign in to comment.