Skip to content

Commit

Permalink
fix locking on ending execution (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
withinboredom authored Jun 25, 2023
1 parent 8c7d9cd commit 7273148
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/OrchestrationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ function(Event $event, string $eventIdentity) use ($identity) {
)
);
}
$this->history->locks = [];
});
}

Expand Down
12 changes: 12 additions & 0 deletions src/State/OrchestrationHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
use Bottledcode\DurablePhp\Events\StartOrchestration;
use Bottledcode\DurablePhp\Events\TaskCompleted;
use Bottledcode\DurablePhp\Events\TaskFailed;
use Bottledcode\DurablePhp\Events\WithEntity;
use Bottledcode\DurablePhp\Events\WithLock;
use Bottledcode\DurablePhp\Events\WithOrchestration;
use Bottledcode\DurablePhp\Exceptions\ExternalException;
use Bottledcode\DurablePhp\Exceptions\Unwind;
Expand Down Expand Up @@ -179,6 +181,16 @@ private function construct(): \Generator
$e->getTraceAsString(),
$e::class
);
} finally {
if (!$this->isRunning()) {
// ok, we now need to release all of the locks that we have
foreach ($this->locks as $lock) {
yield WithLock::onEntity(
$this->id,
WithEntity::forInstance($lock, RaiseEvent::forUnlock($this->id->id, null, null))
);
}
}
}

$completion = WithOrchestration::forInstance(StateId::fromInstance($this->instance), $completion);
Expand Down

0 comments on commit 7273148

Please sign in to comment.