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

Ruby Reaper active check incorrect #557

Closed
courtneymiller2010 opened this issue Jan 6, 2021 · 4 comments · Fixed by #558
Closed

Ruby Reaper active check incorrect #557

courtneymiller2010 opened this issue Jan 6, 2021 · 4 comments · Fixed by #558
Assignees
Milestone

Comments

@courtneymiller2010
Copy link

courtneymiller2010 commented Jan 6, 2021

Describe the bug
The ruby reaper is reaping active jobs. It appears the job json being returned from sidekiq is different than what is expected.

Expected behavior
If a job is active, it shouldn't be reaped.

Current behavior
The ruby reaper is reaping active jobs.

Worker class

module Debugging
  class ProcessWorker
    include Sidekiq::Worker
    sidekiq_options queue: "default", retry: 0, lock: :until_executed, on_conflict: :log

    def perform
      puts "Starting ProcessWorker"
      sleep(5)
      puts "Finishing ProcessWorker"
    end
  end
end

Additional context

sidekiq: v5.2.9
sidekiq-unique-jobs: v7.0.0.beta27

I believe the problem is here:
return true if load_json(job)[LOCK_DIGEST] == digest

If I log load_json(job), this is what I get:

{
 queue: "default",
 payload: {
   class: "Debugging::ProcessWorker",
   args: [],
   retry: 0,
   queue: "default",
   lock: "until_executed",
   on_conflict: "log",
   jid: "c81cb486b2d73357d97e57ba",
   created_at: 1609964935.1892679,
   lock_timeout 0,
   lock_ttl: nil,
   lock_prefix: "uniquejobs",
   lock_args: [],
   lock_digest: "uniquejobs:512613aedf8d8099a473a343e0bc352c",
   enqueued_at: 1609964935.202131
 },
 run_at: 1609964935
}

Replacing that line with the below fixes the issue for me:
return true if load_json(job)["payload"][LOCK_DIGEST] == digest

@mhenrixon
Copy link
Owner

Doh! Nice find :) I'll see about getting that fixed

mhenrixon added a commit that referenced this issue Jan 7, 2021
mhenrixon added a commit that referenced this issue Jan 7, 2021
* Fix active check for the worker hash

Close #557

* Fix test and add constant

* Mandatory rubocop commit

* Mandatory rubocop commit

* Fix spec for 5.2
@mhenrixon
Copy link
Owner

Released as v7.0.0.beta28

@mhenrixon mhenrixon self-assigned this Jan 7, 2021
@mhenrixon mhenrixon added this to the V7.0 milestone Jan 7, 2021
@mhenrixon
Copy link
Owner

PS. I am impressed with the find @courtneymiller2010, I know the gem isn't super easy to debug!

@courtneymiller2010
Copy link
Author

@mhenrixon Thanks for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants