Skip to content

Commit a9f22e3

Browse files
use strict nondeterminism option to enable/disable new checks
1 parent cac1c4d commit a9f22e3

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

internal/internal_activity.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -432,10 +432,9 @@ func deSerializeFunctionResult(f interface{}, result []byte, to interface{}, dat
432432
}
433433

434434
// For everything we return result.
435-
// TODO(remove comment):
436-
// Code reaches here for 2 cases
437-
// 1. activity is executed by name (not the func pointer) and it wasn't registered
438-
// 2. activity is executed by func pointer and the signature indicates it doesn't/can't return data.
435+
// Code reaches here for 2 cases:
436+
// 1. activity is executed by name (not the func pointer) and it wasn't registered
437+
// 2. activity is executed by func pointer and the signature indicates it doesn't/can't return data.
439438
// for example it only has one return parameter (which can only be be error).
440439
return decodeArg(dataConverter, result, to)
441440
}

internal/internal_task_handlers.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,8 @@ ProcessEvents:
932932
isLast := !isInReplay && i == len(reorderedEvents)-1
933933
if !skipReplayCheck {
934934
isDecisionEventFn := isDecisionEvent
935-
if isInReplay {
935+
// when strict nondeterminism is enabled we use a different function to check for decision events during replay
936+
if !w.wth.disableStrictNonDeterminism && isInReplay {
936937
isDecisionEventFn = isDecisionEventForReplay
937938
}
938939

@@ -957,10 +958,15 @@ ProcessEvents:
957958
return nil, err
958959
}
959960

960-
// Break the event processing loop if the workflow is completed except in replay mode.
961-
// In replay mode we check for nondeterminism cases and
962-
// breaking the loop causes missing events in respondEvents which then causes false positives or false negatives.
963-
if w.isWorkflowCompleted && !isInReplay {
961+
// Break the event processing loop if either
962+
// - Workflow is completed AND strict nondeterminism checks disabled.
963+
// - Workflow is completed AND strict nondeterminism checks enabled AND NOT in replay mode.
964+
// With strict nondeterminism checks enabled, breaking the loop early causes missing events
965+
// in respondEvents which then causes false positives or false negatives.
966+
stopProcessing := (w.isWorkflowCompleted && w.wth.disableStrictNonDeterminism) ||
967+
(w.isWorkflowCompleted && !w.wth.disableStrictNonDeterminism && !isInReplay)
968+
969+
if stopProcessing {
964970
break ProcessEvents
965971
}
966972
}
@@ -1046,7 +1052,7 @@ ProcessEvents:
10461052
// workflow timeout.
10471053
return nil, nonDeterministicErr
10481054
default:
1049-
panic(fmt.Sprintf("unknown mismatched workflow history policy."))
1055+
panic("unknown mismatched workflow history policy.")
10501056
}
10511057
}
10521058

0 commit comments

Comments
 (0)