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

while_executing jobs being dropped #749

Closed
RobsonKing opened this issue Dec 22, 2022 · 4 comments
Closed

while_executing jobs being dropped #749

RobsonKing opened this issue Dec 22, 2022 · 4 comments

Comments

@RobsonKing
Copy link

RobsonKing commented Dec 22, 2022

Describe the bug
I am trying to use while_executing like the example in the myapp

I queue multiple of these jobs from the console

MonitorWorker.perform_async
MonitorWorker.perform_async

I expect the second job to run after the first job has finished.
Am I reading the documentation wrong? Is this not how it is supposed to work?

Expected behavior
I expect them to run one at a time.

Current behavior
jobs are skipped with

2022-12-22T23:36:57.229Z pid=1 tid=ovspqt5hl class=MonitorWorker jid=528c5d2ff25cd2cb414348b6 uniquejobs=server while_executing=uniquejobs:58b7929b9a8065c042fdf26167eed18e:RUN INFO: Skipping job with id (528c5d2ff25cd2cb414348b6) because lock_digest: (uniquejobs:58b7929b9a8065c042fdf26167eed18e:RUN) already exists

Worker class

class MonitorWorker
  include Sidekiq::Worker
  sidekiq_options queue: 'default',lock: :while_executing,
  lock_timeout: 100,
  lock_ttl: nil,
  lock_limit: 1,
  on_conflict: :reschedule

  def perform(thing)
     Rails.logger.debug "Starting"
     sleep(1)
     Rails.logger.debug "awake"
  end
end
@mhenrixon
Copy link
Owner

That is how it is expected to work. You'd have to use a conflict strategy if you want to handle it.

There is no preventing both jobs from starting at the same time, only that they don't execute simultaneously.

@RobsonKing
Copy link
Author

Thanks for the quick reply,

I will investigate more after the holidays.

So if I want to move jobs to the schedule queue (or just allow them to execute after one has finished), rather than skipping then I should try a custom on_conflict strategy?

@strika
Copy link

strika commented Dec 26, 2022

That is how it is expected to work. You'd have to use a conflict strategy if you want to handle it.

Is that really true? Note that @RobsonKing is using the "reschedule" strategy in the example. Shouldn't that cause both jobs to be executed?

@RobsonKing
Copy link
Author

I figured out my problem. I was changing my on_conflict strategy but not reloading my rails console. As a result things behaved like :log when I thought it was set to :reschedule. 🤕

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

3 participants