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

Typo in documentation #423

Closed
korrs opened this issue Sep 24, 2019 · 1 comment
Closed

Typo in documentation #423

korrs opened this issue Sep 24, 2019 · 1 comment

Comments

@korrs
Copy link

korrs commented Sep 24, 2019

Description about lock_timeout for while executing strategy says:

NOTE Unless this job is configured with a lock_timeout: nil or lock_timeout: > 0 then all jobs that are attempted to be executed will just be dropped without waiting.

But if i run a simple test worker with option lock_timeout: nil many times

3.times { TestWorker.perform_async }

i see in console result(9 lines) from all executed jobs.
When i set lock_timeout: 2 it works nice, i see result only from first job(3 lines).

Worker class

class TestWorker
  include Sidekiq::Worker
  sidekiq_options lock: :while_executing, lock_timeout: nil

  def perform
    3.times do |t|
      puts "#{t} - #{Time.now.to_s(:db)}"
      sleep 1
    end
  end
end

Seems this is a typo in description, or not?

@mhenrixon
Copy link
Owner

It seems to me that you might not understand how Sidekiq works. Let me try and explain it to you.

If you think of WhileExecuting as WhilePerform or DuringWorkerPerfrom you quickly realize that the job isn't locked/prevented when it is pushed to sidekiq. Only when the Sidekiq::Processor is picking the job off the queue.

This means that if you set lock_timeout: nil each sidekiq worker will wait indefinitely for a lock to become available (dangerous as you might actually run out of sidekiq workers available to process jobs).

When you say that you will wait 2 seconds and the job sleeps for 1 second that should mean that if you send in 6 jobs, 3 of those will complete. If you set it to nil, all of those jobs should complete.

If you set it to zero, most likely, only one of them will complete as the others are dropped because they are considered duplicates.

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