Throw if the server workflow progress is below the progress known to the Workflow Worker
@@ -177,12 +177,18 @@ public final class WorkflowStateMachines {
* and triggered a replay or an execution
*/
public void setStartedIds(long previousStartedEventId, long workflowTaskStartedEventId) {
+ if (previousStartedEventId < currentStartedEventId) {
+ // if previousStartedEventId < currentStartedEventId - the last workflow task handled by these
+ // state machines is ahead of the last handled workflow task known by the server. Something is
+ // off, the server lost progress.
+ throw new IllegalStateException(
+ "Server history for the workflow is below the progress of the workflow on the worker, the progress needs to be discarded");
+ }
this.previousStartedEventId = previousStartedEventId;
this.workflowTaskStartedEventId = workflowTaskStartedEventId;
// if previousStartedEventId == currentStartedEventId -
- // we just apply events generated by this workflow task during execution, it's not a replay
- // if previousStartedEventId < currentStartedEventId - we are clearly already ahead all
- // successful history
+ // we just apply events generated by this workflow task during execution and state a new WFt,
+ // it's not a replay.
this.replaying = previousStartedEventId > currentStartedEventId;
}
