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

Commit

Permalink
fix for update task during retry workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
apanicker-nflx committed Jan 17, 2019
1 parent a9a15de commit cca9912
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Expand Up @@ -408,6 +408,11 @@ public void retry(String workflowId) {
throw new ApplicationException(CONFLICT,
"There are no failed tasks! Use restart if you want to attempt entire workflow execution again.");
}

// set workflow to RUNNING status
workflow.setStatus(WorkflowStatus.RUNNING);
executionDAOFacade.updateWorkflow(workflow);

List<Task> rescheduledTasks = new ArrayList<>();
failedTasks.forEach(failedTask -> rescheduledTasks.add(taskToBeRescheduled(failedTask)));

Expand All @@ -421,9 +426,6 @@ public void retry(String workflowId) {
}
});

workflow.setStatus(WorkflowStatus.RUNNING);
executionDAOFacade.updateWorkflow(workflow);

scheduleTask(workflow, rescheduledTasks);
executionDAOFacade.updateTasks(workflow.getTasks());

Expand Down Expand Up @@ -463,10 +465,7 @@ private Task taskToBeRescheduled(Task task) {
taskToBeRetried.setRetried(false);
taskToBeRetried.setPollCount(0);
taskToBeRetried.setCallbackAfterSeconds(0);

// update the failed task in the DAO
task.setRetried(true);
executionDAOFacade.updateTask(task);
return taskToBeRetried;
}

Expand Down
Expand Up @@ -530,9 +530,9 @@ public void testRetryWorkflow() {
return null;
}).when(executionDAOFacade).updateTasks(any());

AtomicInteger updateTasksAlledCounter = new AtomicInteger(0);
AtomicInteger updateTaskCalledCounter = new AtomicInteger(0);
doAnswer(invocation -> {
updateTasksCalledCounter.incrementAndGet();
updateTaskCalledCounter.incrementAndGet();
return null;
}).when(executionDAOFacade).updateTask(any());

Expand Down Expand Up @@ -596,7 +596,8 @@ public void testRetryWorkflow() {

assertEquals(Workflow.WorkflowStatus.COMPLETED, workflow.getStatus());
assertEquals(2, updateWorkflowCalledCounter.get());
assertEquals(7, updateTasksCalledCounter.get());
assertEquals(2, updateTasksCalledCounter.get());
assertEquals(0, updateTaskCalledCounter.get());
assertEquals(1, removeQueueEntryCalledCounter.get());
}

Expand Down

0 comments on commit cca9912

Please sign in to comment.