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

A worker with "While Executing" lock and "Reschedule" strategy is rescheduled forever #457

Closed
bunyan opened this issue Nov 28, 2019 · 7 comments · Fixed by #460
Closed
Assignees
Labels

Comments

@bunyan
Copy link

bunyan commented Nov 28, 2019

Describe the bug
A worker with lock: :while_executing and on_conflict: :reschedule is being rescheduled in a loop after completion.

Expected behavior
Usual Sidekiq worker behaviour, i.e. job being removed from queue after execution.

Current behavior
"Reschedule" strategy runs after the worker code is executed scheduling it to be run again 5 seconds after completion.

Worker class

class Job
  include Sidekiq::Worker

  sidekiq_options lock: :while_executing,
                  lock_timeout: 5, 
                  on_conflict: :reschedule

  def perform
    puts 'hello'
    sleep 1
    puts 'bye'
  end
end

Additional context
I believe the problem is here - whether the strategy will be called or not relies on the result of the callback_safely which by default returns nil. If I add a callback to the worker class like

def after_unlock
  true
end

everything works as expected.

@mhenrixon
Copy link
Owner

Which version of the gem are you using @bunyan?

@mhenrixon mhenrixon added the bug label Nov 28, 2019
@mhenrixon mhenrixon self-assigned this Nov 28, 2019
@bunyan
Copy link
Author

bunyan commented Nov 28, 2019

@mhenrixon,
sidekiq-unique-jobs is 7.0.0.beta5
sidekiq is 6.0.1
Ruby version is 2.5.6

@mhenrixon
Copy link
Owner

I'll get it fixed right away @bunyan

@mhenrixon
Copy link
Owner

Will be fixed in beta7 @bunyan. Should be released in 10 minutes or so

@bunyan
Copy link
Author

bunyan commented Nov 28, 2019

Great, thank you @mhenrixon!

@mhenrixon
Copy link
Owner

Try the new version, now I also have a regression test for it!

@bunyan
Copy link
Author

bunyan commented Nov 28, 2019

Works fine now with the beta7 👍🏻

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

Successfully merging a pull request may close this issue.

2 participants