Skip to content

Commit

Permalink
Fixed problem with rolling back when there was a transaction running …
Browse files Browse the repository at this point in the history
…on the main thread.
  • Loading branch information
roidrage committed Mar 19, 2009
1 parent 929b72d commit 3c02c51
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ If one of your tasks ran in a transaction block and issued a rollback,
parallelize will rollback all other threads, if they have rollback statements
defined.

Known Issues
============

Due to the threading you have to be sure to already have authenticated your SSH
key (you're using SSH keys, right?) using an SSH agent before you run the
parallelized code. Otherwise it'll blow up, let's just leave it at that. That'll
change in the future.

Installation
============

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def wait_for(threads)
thread.join
rescue
logger.important "Subthread failed: #{$!.message}"
thread[:exception_raised] = $!
end
end
end
Expand Down
13 changes: 11 additions & 2 deletions lib/capistrano/configuration/extensions/execution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,22 @@ def current_task
all_task_call_frames.last.task
end

def transaction
def transaction?
!(rollback_requests.nil? && Thread.main[:rollback_requests].nil?)
end

def transaction(&blk)
super do
self.rollback_requests = [] unless transaction?
yield
blk.call
end
end

def on_rollback(&block)
self.rollback_requests ||= [] if transaction?
super
end

def rollback!
return if Thread.current[:rollback_requests].nil?
Thread.current[:rolled_back] = true
Expand Down

0 comments on commit 3c02c51

Please sign in to comment.