Skip to content

Commit

Permalink
use strict nondeterminism option to enable/disable new checks
Browse files Browse the repository at this point in the history
  • Loading branch information
taylanisikdemir committed Nov 7, 2023
1 parent cac1c4d commit a9f22e3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
7 changes: 3 additions & 4 deletions internal/internal_activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,9 @@ func deSerializeFunctionResult(f interface{}, result []byte, to interface{}, dat
}

// For everything we return result.
// TODO(remove comment):
// Code reaches here for 2 cases
// 1. activity is executed by name (not the func pointer) and it wasn't registered
// 2. activity is executed by func pointer and the signature indicates it doesn't/can't return data.
// Code reaches here for 2 cases:
// 1. activity is executed by name (not the func pointer) and it wasn't registered
// 2. activity is executed by func pointer and the signature indicates it doesn't/can't return data.
// for example it only has one return parameter (which can only be be error).
return decodeArg(dataConverter, result, to)
}
Expand Down
18 changes: 12 additions & 6 deletions internal/internal_task_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,8 @@ ProcessEvents:
isLast := !isInReplay && i == len(reorderedEvents)-1
if !skipReplayCheck {
isDecisionEventFn := isDecisionEvent
if isInReplay {
// when strict nondeterminism is enabled we use a different function to check for decision events during replay
if !w.wth.disableStrictNonDeterminism && isInReplay {
isDecisionEventFn = isDecisionEventForReplay
}

Expand All @@ -957,10 +958,15 @@ ProcessEvents:
return nil, err
}

// Break the event processing loop if the workflow is completed except in replay mode.
// In replay mode we check for nondeterminism cases and
// breaking the loop causes missing events in respondEvents which then causes false positives or false negatives.
if w.isWorkflowCompleted && !isInReplay {
// Break the event processing loop if either
// - Workflow is completed AND strict nondeterminism checks disabled.
// - Workflow is completed AND strict nondeterminism checks enabled AND NOT in replay mode.
// With strict nondeterminism checks enabled, breaking the loop early causes missing events
// in respondEvents which then causes false positives or false negatives.
stopProcessing := (w.isWorkflowCompleted && w.wth.disableStrictNonDeterminism) ||
(w.isWorkflowCompleted && !w.wth.disableStrictNonDeterminism && !isInReplay)

if stopProcessing {
break ProcessEvents
}
}
Expand Down Expand Up @@ -1046,7 +1052,7 @@ ProcessEvents:
// workflow timeout.
return nil, nonDeterministicErr
default:
panic(fmt.Sprintf("unknown mismatched workflow history policy."))
panic("unknown mismatched workflow history policy.")
}
}

Expand Down

0 comments on commit a9f22e3

Please sign in to comment.