Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Commit

Permalink
during start, decide is performed inside a lock
Browse files Browse the repository at this point in the history
  • Loading branch information
aravindanr committed Sep 2, 2022
1 parent 7528e80 commit b17ede7
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,7 @@ public String startWorkflow(
}

try {
createWorkflow(workflow);
executionDAOFacade.populateWorkflowAndTaskPayloadData(workflow);
// then decide to see if anything needs to be done as part of the workflow
decide(workflow);
createAndDecide(workflow);
Monitors.recordWorkflowStartSuccess(
workflow.getWorkflowName(),
String.valueOf(workflow.getWorkflowVersion()),
Expand All @@ -405,7 +402,7 @@ public String startWorkflow(
* Acquire and hold the lock till the workflow creation action is completed (in primary and secondary datastores).
* This is to ensure that workflow creation action precedes any other action on a given workflow.
*/
private void createWorkflow(WorkflowModel workflow) {
private void createAndDecide(WorkflowModel workflow) {
if (!executionLockService.acquireLock(workflow.getWorkflowId())) {
throw new TransientException("Error acquiring lock when creating workflow: {}");
}
Expand All @@ -415,6 +412,8 @@ private void createWorkflow(WorkflowModel workflow) {
"A new instance of workflow: {} created with id: {}",
workflow.getWorkflowName(),
workflow.getWorkflowId());
executionDAOFacade.populateWorkflowAndTaskPayloadData(workflow);
decide(workflow);
} finally {
executionLockService.releaseLock(workflow.getWorkflowId());
}
Expand Down

0 comments on commit b17ede7

Please sign in to comment.