Skip to content

Commit

Permalink
Don't ack unless we actually started working on the job. Fixes sideki…
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjay committed Sep 9, 2015
1 parent cbc0254 commit 371dc81
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/sidekiq/processor.rb
Expand Up @@ -40,7 +40,7 @@ def process(work)

@boss.async.real_thread(proxy_id, Thread.current)

ack = true
ack = false
begin
msg = Sidekiq.load_json(msgstr)
klass = msg['class'].constantize
Expand All @@ -49,9 +49,14 @@ def process(work)

stats(worker, msg, queue) do
Sidekiq.server_middleware.invoke(worker, msg, queue) do
# Only ack if we either attempted to start this job or
# successfully completed it. This prevents us from
# losing jobs if a middleware raises an exception before yielding
ack = true
execute_job(worker, cloned(msg['args']))
end
end
ack = true
rescue Sidekiq::Shutdown
# Had to force kill this job because it didn't finish
# within the timeout. Don't acknowledge the work since
Expand Down

0 comments on commit 371dc81

Please sign in to comment.