Handle shutdown race condition, fixes #134

This commit is contained in:
Mike Perham 2012-04-16 20:18:48 -07:00
parent d57cf12c97
commit bc09ccd477
4 changed files with 20 additions and 9 deletions

View File

@ -1,8 +1,8 @@
HEAD
1.1.1
-----------
- Fix hang with sidekiq:start [#131]
- Fix race condition on shutdown [#134]
- Fix hang with cap sidekiq:start [#131]
1.1.0
-----------
@ -30,7 +30,6 @@ Sidekiq.configure_server do |config|
end
```
1.0.0
-----------

View File

@ -4,6 +4,8 @@ gemspec
gem 'slim'
gem 'sprockets'
gem 'sass'
gem 'rails'
gem 'sqlite3'
group :test do
gem 'simplecov', :require => false

View File

@ -97,10 +97,20 @@ module Sidekiq
def assign(msg, queue)
watchdog("Manager#assign died") do
processor = @ready.pop
@in_progress[processor.object_id] = [msg, queue]
@busy << processor
processor.process!(MultiJson.decode(msg), queue)
if stopped?
# Race condition between Manager#stop if Fetcher
# is blocked on redis and gets a message after
# all the ready Processors have been stopped.
# Push the message back to redis.
Sidekiq.redis do |conn|
conn.lpush("queue:#{queue}", msg)
end
else
processor = @ready.pop
@in_progress[processor.object_id] = [msg, queue]
@busy << processor
processor.process!(MultiJson.decode(msg), queue)
end
end
end

View File

@ -1,3 +1,3 @@
module Sidekiq
VERSION = "1.1.0"
VERSION = "1.1.1"
end