@@ -268,6 +268,10 @@ func (eh *history) NextDecisionEvents() (result []*s.HistoryEvent, markers []*s.
268
268
return result , markers , checksum , err
269
269
}
270
270
271
+ func (eh * history ) HasNextDecisionEvents () bool {
272
+ return len (eh .next ) != 0 || eh .currentIndex != len (eh .loadedEvents ) || eh .hasMoreEvents ()
273
+ }
274
+
271
275
func (eh * history ) hasMoreEvents () bool {
272
276
historyIterator := eh .workflowTask .historyIterator
273
277
return historyIterator != nil && historyIterator .HasNextPage ()
@@ -468,7 +472,7 @@ func (w *workflowExecutionContextImpl) Lock() {
468
472
469
473
func (w * workflowExecutionContextImpl ) Unlock (err error ) {
470
474
if err != nil || w .err != nil || w .isWorkflowCompleted || (w .wth .disableStickyExecution && ! w .hasPendingLocalActivityWork ()) {
471
- // TODO: in case of closed, it asumes the close decision always succeed. need server side change to return
475
+ // TODO: in case of closed, it assumes the close decision always succeed. need server side change to return
472
476
// error to indicate the close failure case. This should be rear case. For now, always remove the cache, and
473
477
// if the close decision failed, the next decision will have to rebuild the state.
474
478
if getWorkflowCache ().Exist (w .workflowInfo .WorkflowExecution .RunID ) {
@@ -818,6 +822,7 @@ func (w *workflowExecutionContextImpl) ProcessWorkflowTask(workflowTask *workflo
818
822
var respondEvents []* s.HistoryEvent
819
823
820
824
skipReplayCheck := w .skipReplayCheck ()
825
+ isReplayTest := task .GetPreviousStartedEventId () == replayPreviousStartedEventID
821
826
// Process events
822
827
ProcessEvents:
823
828
for {
@@ -888,7 +893,8 @@ ProcessEvents:
888
893
}
889
894
}
890
895
isReplay := len (reorderedEvents ) > 0 && reorderedHistory .IsReplayEvent (reorderedEvents [len (reorderedEvents )- 1 ])
891
- if isReplay {
896
+ lastDecisionEventsForReplayTest := isReplayTest && ! reorderedHistory .HasNextDecisionEvents ()
897
+ if isReplay && ! lastDecisionEventsForReplayTest {
892
898
eventDecisions := eventHandler .decisionsHelper .getDecisions (true )
893
899
if len (eventDecisions ) > 0 && ! skipReplayCheck {
894
900
replayDecisions = append (replayDecisions , eventDecisions ... )
@@ -904,14 +910,14 @@ ProcessEvents:
904
910
// the replay of that event will panic on the decision state machine and the workflow will be marked as completed
905
911
// with the panic error.
906
912
var nonDeterministicErr error
907
- if ! skipReplayCheck && ! w .isWorkflowCompleted {
913
+ if ! skipReplayCheck && ! w .isWorkflowCompleted || isReplayTest {
908
914
// check if decisions from reply matches to the history events
909
915
if err := matchReplayWithHistory (replayDecisions , respondEvents ); err != nil {
910
916
nonDeterministicErr = err
911
917
}
912
918
}
913
919
if nonDeterministicErr == nil && w .err != nil {
914
- if panicErr , ok := w .err .(* PanicError ); ok && panicErr .value != nil {
920
+ if panicErr , ok := w .err .(* workflowPanicError ); ok && panicErr .value != nil {
915
921
if _ , isStateMachinePanic := panicErr .value .(stateMachineIllegalStatePanic ); isStateMachinePanic {
916
922
nonDeterministicErr = panicErr
917
923
}
@@ -1445,7 +1451,7 @@ func (wth *workflowTaskHandlerImpl) completeWorkflow(
1445
1451
// for query task
1446
1452
if task .Query != nil {
1447
1453
queryCompletedRequest := & s.RespondQueryTaskCompletedRequest {TaskToken : task .TaskToken }
1448
- if panicErr , ok := workflowContext .err .(* PanicError ); ok {
1454
+ if panicErr , ok := workflowContext .err .(* workflowPanicError ); ok {
1449
1455
queryCompletedRequest .CompletedType = common .QueryTaskCompletedTypePtr (s .QueryTaskCompletedTypeFailed )
1450
1456
queryCompletedRequest .ErrorMessage = common .StringPtr ("Workflow panic: " + panicErr .Error ())
1451
1457
return queryCompletedRequest
0 commit comments