Permalink
Browse files

Don't close unopened transactions.

  • Loading branch information...
1 parent 5aa2e7c commit 8fedf93257ae1bfe57b93d2eb3fe2da290e104b2 Evan Weaver committed Oct 6, 2010
Showing with 4 additions and 2 deletions.
  1. +4 −2 lib/kestrel/client/transactional.rb
@@ -42,7 +42,7 @@ def initialize(client, max_retries = nil, error_rate = nil)
def get(key, opts = {})
raise MultipleQueueException if current_queue && key != current_queue
- close_transaction(current_try == 1 ? key : "#{key}_errors")
+ close_transaction(current_try == 1 ? key : "#{key}_errors") if @current_queue
queue = (rand < @error_rate) ? key + "_errors" : key
@@ -81,9 +81,11 @@ def retry(item = nil)
if should_retry = job.retries < @max_retries
client.set(current_queue + "_errors", job)
+ else
+ @current_queue = nil
end
- # close the transaction on the original queue if this is the first retry
+ # close the transaction on the original queue
close_transaction(job.retries == 1 ? current_queue : "#{current_queue}_errors")
should_retry

0 comments on commit 8fedf93

Please sign in to comment.