Skip to content

Commit

Permalink
Improve error message when a workflow's decision is rejected due to c…
Browse files Browse the repository at this point in the history
…oncurrent changes (cadence-workflow#4673)

When a workflow e.g. receives a signal while processing a decision task, the task's result
will not be applied, and an 'Unhandled decision' error will be returned.  The next decision
task will (hopefully) produce a new set of decisions that take that signal into account.

When this error is returned, in the UI it currently shows as a decision-task-failed with
these details:
```
cause   UNHANDLED_DECISION
details []
```
which is extremely unclear to users.  After this change, hopefully it will be easier to
understand.
  • Loading branch information
Groxx authored Dec 7, 2021
1 parent c220950 commit f300344
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions service/history/decision/task_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,10 @@ func (handler *taskHandlerImpl) handleDecisionCompleteWorkflow(
)

if handler.hasUnhandledEventsBeforeDecisions {
return handler.handlerFailDecision(types.DecisionTaskFailedCauseUnhandledDecision, "")
return handler.handlerFailDecision(
types.DecisionTaskFailedCauseUnhandledDecision,
"cannot complete workflow, new pending decisions were scheduled while this decision was processing",
)
}

if err := handler.validateDecisionAttr(
Expand Down Expand Up @@ -472,7 +475,10 @@ func (handler *taskHandlerImpl) handleDecisionFailWorkflow(
)

if handler.hasUnhandledEventsBeforeDecisions {
return handler.handlerFailDecision(types.DecisionTaskFailedCauseUnhandledDecision, "")
return handler.handlerFailDecision(
types.DecisionTaskFailedCauseUnhandledDecision,
"cannot complete workflow, new pending decisions were scheduled while this decision was processing",
)
}

if err := handler.validateDecisionAttr(
Expand Down Expand Up @@ -602,7 +608,10 @@ func (handler *taskHandlerImpl) handleDecisionCancelWorkflow(
metrics.DecisionTypeCancelWorkflowCounter)

if handler.hasUnhandledEventsBeforeDecisions {
return handler.handlerFailDecision(types.DecisionTaskFailedCauseUnhandledDecision, "")
return handler.handlerFailDecision(
types.DecisionTaskFailedCauseUnhandledDecision,
"cannot process cancellation, new pending decisions were scheduled while this decision was processing",
)
}

if err := handler.validateDecisionAttr(
Expand Down Expand Up @@ -723,7 +732,10 @@ func (handler *taskHandlerImpl) handleDecisionContinueAsNewWorkflow(
)

if handler.hasUnhandledEventsBeforeDecisions {
return handler.handlerFailDecision(types.DecisionTaskFailedCauseUnhandledDecision, "")
return handler.handlerFailDecision(
types.DecisionTaskFailedCauseUnhandledDecision,
"cannot complete workflow, new pending decisions were scheduled while this decision was processing",
)
}

executionInfo := handler.mutableState.GetExecutionInfo()
Expand Down

0 comments on commit f300344

Please sign in to comment.