-
-
Notifications
You must be signed in to change notification settings - Fork 279
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
Deadlock using :while_executing? #233
Comments
Well first of all you'd have to provide some more details for me to be able to make any suggestions. Have you tried turning on debug logging? What does your worker class look like? How have you configured the gem? What sidekiq version? Are you using Activejob? etc. |
@mhenrixon Hey thanks for jumping in
class UniqueAchievementCardScoreWorker
include Sidekiq::Worker
sidekiq_options queue: 'unique_achievement_card_scores',
unique: :while_executing,
unique_args: ->(args) { [args.last] }
def perform(challenge_attempt_id, child_id)
challenge_attempt = ChallengeAttempt.find(challenge_attempt_id) # Locks Here
child_id = challenge_attempt.child_id
achievement_cards = challenge_attempt.achievement_cards
# init a Calculator and run update_score
calculator = UniqueAchievementCardScoreCalculator.new(challenge_attempt)
calculator.update_score
# get all parent achievement cards we need to update (remove duplicates and nils)
parent_achievement_card_ids = achievement_cards.collect(&:parent_id).uniq.compact
# create one job for each parent
parent_achievement_card_ids.each do |achievement_card_id|
CompositeAchievementCardScoreWorker.perform_async(achievement_card_id, child_id)
end
end
end All the code here and the classes don't have anything fancy, just Ruby and ActiveRecord
Looks like it locks when calling ActiveRecord. I added more connections to the pool but still hangs there. Looking at the |
Oh one more thing, I'm using postgres with the |
Related to #230 |
@mhenrixon if you want to replicate this just:
I just removed the library and works as expected and I'll take a look next week (we are just making a release today and I had to disable unique-jobs to make it happen). If you find something please let me know |
@orlando if you wanted to help test the branch better-runtime-locks that would be amazing. I am reworking the while executing lock but before I optimise anything I want to see if it works better. |
I also get this issue. All jobs lock for exactly 1-3 minutes. I'm using Sidekiq 5.0.4 and Unique Jobs 5.0.10. My use case is very similar to orlando's |
@mhenrixon using unique jobs 5.0.9 I just ran into the same issue probably. It seems that, on 1 sidekiq worker, there can be only 1 uniq while_executing job running at the time. The rest just blocks until the running one is completed. Looking at the code it seems that 1 global mutex is used around all while_executing locks. This explains why only 1 while_executing job runs on a particular worker. |
Please try the master branch if possible. Would be great to hear if that refactoring does anything to improve the situation. |
…ng with 0 busy. Might be mhenrixon/sidekiq-unique-jobs#233?
Hello,
I'm using this library to allow to enqueue multiple jobs but only process 1 job of a time for a certain parameter (in our case a model id).
If I enqueue multiple jobs with no workers running, when I start a worker it deadlocks trying to run multiple jobs of the same parameter at the same time.
Any suggestions?
The text was updated successfully, but these errors were encountered: