In my project, we are starting to add some error handling to our workflows and we came up using the Saga mechanism and adding compensations whenever it was needed.
private var sagaOpts = new Saga.Options.Builder().setParallelCompensation(true).build();
final var saga = new Saga(SAGA_OPTS);
try {
activity.operation1();
saga.addCompensation(activity::operation1Compenstation);
activity.operation2();
saga.addCompensation(activity::operation2Compenstation);
...
} catch (ActivityFailure e) {
saga.compensate();
throw e;
}
After some testing, we tested what happens if the compensations fail (configuring the saga options to run in parallel and also to not continue on error).
What we are seeing is that after the compensation fails and all retries are reached, in the Temporal UI appears a new event WorkflowTaskFailed
in the History tab.
io.temporal.internal.replay.InternalWorkflowTaskException: Failure handling event 27 of 'EVENT_TYPE_WORKFLOW_TASK_STARTED' type. IsReplaying=false, PreviousStartedEventId=27, workflowTaskStartedEventId=27, Currently Processing StartedEventId=27
....
Caused By: java.lang.RuntimeException: WorkflowTask: failure executing SCHEDULED->WORKFLOW_TASK_STARTED, transition history is [CREATED->WORKFLOW_TASK_SCHEDULED]
...
Caused By: io.temporal.workflow.Saga$CompensationException: Exception from saga compensate
The issue is the workflow stays in RUNNING state forever, and I have a couple questions:
- Is this the expected behavior?
- Is there any documentation I can read regarding this behavior? I wasn’t able to find any.