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

Duplicate job was pushed ( v6.0.13 ) #414

Closed
metapraveen opened this issue Aug 2, 2019 · 5 comments
Closed

Duplicate job was pushed ( v6.0.13 ) #414

metapraveen opened this issue Aug 2, 2019 · 5 comments
Assignees

Comments

@metapraveen
Copy link

metapraveen commented Aug 2, 2019

Describe the bug
We have 2 instances running sidekiq, I used this gem to avoid duplication but got duplication.
Gem version 6.0.13

Expected behavior
Jobs pushed should have been unique

Current behavior
I see 2 similar jobs getting pushed

Worker class

class MyWorket
  include Sidekiq::Worker
  sidekiq_options retry: false, lock: :until_executed, on_conflict: :log, log_duplicate_payload: true
  
  def perform(); end
end

Additional context
I would like to debug the gem and see if I can get to the issue, but I may need a starting point to look in the right direction.

@metapraveen metapraveen changed the title Duplicate job was pushed Duplicate job was pushed ( v6.0.13 ) Aug 2, 2019
@mhenrixon
Copy link
Owner

@metapraveen that is a new issue. Version 6 was always pretty bad at keeping locks around for longer than necessary but I haven't had any complaints about duplicate locks.

Are you sure that you are not just seeing a log about duplication because of the on_conflict? If you add a sleep for a few seconds will there really be two jobs executing at the same time?

@mhenrixon mhenrixon self-assigned this Aug 2, 2019
@metapraveen
Copy link
Author

My jobs supposed to make x number of HTTP calls, but it makes 2x in production which means the job is duplicated.
I tried to reproduce this in local by adding a lot of redis latency and pushing around 25 jobs at a time, but this gem seems to handle it perfectly and only one job is executed.
Wish I could replicate this in local easily :(

@kolo
Copy link

kolo commented Sep 3, 2019

I spent some time trying to debug this issue and came to the following conclusion. The bug happens when there is a conflict and log strategy is called. The strategy uses log_info method which returns true value. This value becomes return value of the BaseLock#lock method. Client::Middleware#call interprets this value as if locking was successful and yields next middleware in the chain. This results it queuing of a duplicate job.

I believe this issue has been solved in the master branch because all logging methods in it return nil explicitly.

@mhenrixon
Copy link
Owner

Ah, I'll cut a new release @kolo ! Thanks a bunch for taking the time to both investigate and then present your findings.

@mhenrixon
Copy link
Owner

Fixed in v6.0.14

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

No branches or pull requests

3 participants