You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class SomeWorker
include Sidekiq::Worker
sidekiq_options unique: :while_executing, unique_args: :filtered_args
def self.filtered_args(some_id)
[some_id]
end
def perform(some_id)
puts 'Running ' + some_id.to_s
sleep(5)
end
end
Then, i expected the following behavior:
SomeWorker.perform_async(1) < worker starts immediately
SomeWorker.perform_async(2) < worker starts immediately in a different thread
SomeWorker.perform_async(1) < worker waits while first call is in execution
But, what really happens:
SomeWorker.perform_async(1) < worker starts immediately
SomeWorker.perform_async(2) < worker starts after first call ends
SomeWorker.perform_async(1) < worker starts after second call ends
Am i doing something wrong?
The text was updated successfully, but these errors were encountered:
WhileExecuting will be unique like the name suggests while executing. To begin with.... In your example you have no need for the filtered_args method since the arguments passed to perform will be used for uniqueness if no unique args method or proc is specified. The uniqueness won't stop a job from being started it will just pause there until the lock can be acquired so your assumption of what really happens is wrong. All of the jobs will be passed successfully to the middleware and wait there while trying to acquire the runtime lock/mutex/semaphore or whatever other name you can thing of. As you might have noticed the other locks prevents jobs from being scheduled to a queue and while_executing will allow any number of jobs to be scheduled but only one of those to run at the same time.
I created an worker like that:
Then, i expected the following behavior:
But, what really happens:
Am i doing something wrong?
The text was updated successfully, but these errors were encountered: