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

Job executed twice when reaper runs #738

Closed
strika opened this issue Oct 27, 2022 · 1 comment
Closed

Job executed twice when reaper runs #738

strika opened this issue Oct 27, 2022 · 1 comment

Comments

@strika
Copy link

strika commented Oct 27, 2022

Describe the bug

When I schedule the example job and I run the reaper right after that, the job is executed twice:

irb(main):004:0> TestJob.perform_async
=> "43d17d4476ac148d2b71f73f"
irb(main):005:0> SidekiqUniqueJobs::Orphans::Reaper.call
=> 1

The log:

2022-10-27T14:55:58.030Z pid=21648 tid=81c4 class=TestJob jid=90cc8ddd78537338f0cf0fc5 INFO: start
2022-10-27T14:55:58.050Z pid=21648 tid=81c4 class=TestJob jid=90cc8ddd78537338f0cf0fc5 uniquejobs=server while_executing=uniquejobs:fd25cf3971a244b8d59c48317e631970:RUN INFO: Working 0...
2022-10-27T14:55:59.050Z pid=21648 tid=81c4 class=TestJob jid=90cc8ddd78537338f0cf0fc5 uniquejobs=server while_executing=uniquejobs:fd25cf3971a244b8d59c48317e631970:RUN INFO: Working 1...
2022-10-27T14:56:00.052Z pid=21648 tid=81c4 class=TestJob jid=90cc8ddd78537338f0cf0fc5 uniquejobs=server while_executing=uniquejobs:fd25cf3971a244b8d59c48317e631970:RUN INFO: Working 2...
2022-10-27T14:56:01.053Z pid=21648 tid=81c4 class=TestJob jid=90cc8ddd78537338f0cf0fc5 uniquejobs=server while_executing=uniquejobs:fd25cf3971a244b8d59c48317e631970:RUN INFO: Working 3...
2022-10-27T14:56:02.054Z pid=21648 tid=81c4 class=TestJob jid=90cc8ddd78537338f0cf0fc5 uniquejobs=server while_executing=uniquejobs:fd25cf3971a244b8d59c48317e631970:RUN INFO: Working 4...
2022-10-27T14:56:03.055Z pid=21648 tid=81c4 class=TestJob jid=90cc8ddd78537338f0cf0fc5 uniquejobs=server while_executing=uniquejobs:fd25cf3971a244b8d59c48317e631970:RUN INFO: Working 5...
2022-10-27T14:56:04.057Z pid=21648 tid=81c4 class=TestJob jid=90cc8ddd78537338f0cf0fc5 uniquejobs=server while_executing=uniquejobs:fd25cf3971a244b8d59c48317e631970:RUN INFO: Working 6...
2022-10-27T14:56:05.058Z pid=21648 tid=81c4 class=TestJob jid=90cc8ddd78537338f0cf0fc5 uniquejobs=server while_executing=uniquejobs:fd25cf3971a244b8d59c48317e631970:RUN INFO: Working 7...
2022-10-27T14:56:06.059Z pid=21648 tid=81c4 class=TestJob jid=90cc8ddd78537338f0cf0fc5 uniquejobs=server while_executing=uniquejobs:fd25cf3971a244b8d59c48317e631970:RUN INFO: Working 8...
2022-10-27T14:56:07.060Z pid=21648 tid=81c4 class=TestJob jid=90cc8ddd78537338f0cf0fc5 uniquejobs=server while_executing=uniquejobs:fd25cf3971a244b8d59c48317e631970:RUN INFO: Working 9...
2022-10-27T14:56:08.070Z pid=21648 tid=81c4 class=TestJob jid=90cc8ddd78537338f0cf0fc5 elapsed=10.04 INFO: done
2022-10-27T14:56:18.053Z pid=21648 tid=82o4 class=TestJob jid=1bd75a7cdc5ecb99f8f9826d INFO: start
2022-10-27T14:56:18.060Z pid=21648 tid=82o4 class=TestJob jid=1bd75a7cdc5ecb99f8f9826d uniquejobs=server while_executing=uniquejobs:fd25cf3971a244b8d59c48317e631970:RUN INFO: Working 0...
2022-10-27T14:56:19.061Z pid=21648 tid=82o4 class=TestJob jid=1bd75a7cdc5ecb99f8f9826d uniquejobs=server while_executing=uniquejobs:fd25cf3971a244b8d59c48317e631970:RUN INFO: Working 1...
2022-10-27T14:56:20.062Z pid=21648 tid=82o4 class=TestJob jid=1bd75a7cdc5ecb99f8f9826d uniquejobs=server while_executing=uniquejobs:fd25cf3971a244b8d59c48317e631970:RUN INFO: Working 2...
2022-10-27T14:56:21.062Z pid=21648 tid=82o4 class=TestJob jid=1bd75a7cdc5ecb99f8f9826d uniquejobs=server while_executing=uniquejobs:fd25cf3971a244b8d59c48317e631970:RUN INFO: Working 3...
2022-10-27T14:56:22.063Z pid=21648 tid=82o4 class=TestJob jid=1bd75a7cdc5ecb99f8f9826d uniquejobs=server while_executing=uniquejobs:fd25cf3971a244b8d59c48317e631970:RUN INFO: Working 4...
2022-10-27T14:56:23.064Z pid=21648 tid=82o4 class=TestJob jid=1bd75a7cdc5ecb99f8f9826d uniquejobs=server while_executing=uniquejobs:fd25cf3971a244b8d59c48317e631970:RUN INFO: Working 5...
2022-10-27T14:56:24.065Z pid=21648 tid=82o4 class=TestJob jid=1bd75a7cdc5ecb99f8f9826d uniquejobs=server while_executing=uniquejobs:fd25cf3971a244b8d59c48317e631970:RUN INFO: Working 6...
2022-10-27T14:56:25.067Z pid=21648 tid=82o4 class=TestJob jid=1bd75a7cdc5ecb99f8f9826d uniquejobs=server while_executing=uniquejobs:fd25cf3971a244b8d59c48317e631970:RUN INFO: Working 7...
2022-10-27T14:56:26.067Z pid=21648 tid=82o4 class=TestJob jid=1bd75a7cdc5ecb99f8f9826d uniquejobs=server while_executing=uniquejobs:fd25cf3971a244b8d59c48317e631970:RUN INFO: Working 8...
2022-10-27T14:56:27.069Z pid=21648 tid=82o4 class=TestJob jid=1bd75a7cdc5ecb99f8f9826d uniquejobs=server while_executing=uniquejobs:fd25cf3971a244b8d59c48317e631970:RUN INFO: Working 9...
2022-10-27T14:56:28.078Z pid=21648 tid=82o4 class=TestJob jid=1bd75a7cdc5ecb99f8f9826d elapsed=10.026 INFO: done

Expected behavior

A job that's scheduled once should be executed only once.

Current behavior

A job that's executed when the reaper is executed is scheduled twice.

Worker class

class TestJob
  include Sidekiq::Worker

  sidekiq_options(
    :lock         => :while_executing,
    :on_conflict  => :reschedule
  )

  def perform
    10.times do |i|
      logger.info "Working #{i}..."
      sleep 1
    end
  end
end

Additional context

Ruby version: 3.0.4
Sidekiq version: 6.5.7
sidekiq-unique-jobs version: 7.1.27

@mhenrixon
Copy link
Owner

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

No branches or pull requests

2 participants