Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra disappeared check to avoid false-positives #7 #8

Merged
merged 2 commits into from
Jan 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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