1041
func (m *workflowTaskStateMachine) failWorkflowTask(
1042
incrementAttempt bool,
1044
>
// Get current workflow task info before clearing it, to capture timeout tasks for deletion
1045
>
currentWorkflowTask := m.getWorkflowTaskInfo()
1046
>
m.recordTimeoutTasksForDeletion(currentWorkflowTask)
1047
>
1048
>
// Increment attempts only if workflow task is failing on non-sticky task queue.
1049
>
// If it was sticky task queue, clear sticky task queue first and try again before creating transient workflow task.
1050
>
if m.ms.IsStickyTaskQueueSet() {
1051
incrementAttempt = false
1052
m.ms.ClearStickyTaskQueue()
1053
}
1054
1056
>
newAttempt := int32(1)
1057
>
if incrementAttempt {
1058
>
// Increment the failure counter for this WFT failure
1059
>
newAttemptsSinceLastSuccess = m.ms.executionInfo.WorkflowTaskAttemptsSinceLastSuccess + 1
1060
>
// Also increment Attempt for transient workflow task tracking
1061
>
newAttempt = m.ms.executionInfo.WorkflowTaskAttempt + 1
1062
>
if m.ms.config.EnableWorkflowTaskStampIncrementOnFailure() {
1063
m.ms.executionInfo.WorkflowTaskStamp += 1
1064
}
1065
}
1066
1068
>
Version: common.EmptyVersion,
1069
>
ScheduledEventID: common.EmptyEventID,
1070
>
StartedEventID: common.EmptyEventID,
1071
>
RequestID: emptyUUID,
1072
>
WorkflowTaskTimeout: time.Duration(0),
1073
>
StartedTime: time.Unix(0, 0).UTC(),
1074
>
TaskQueue: nil,
1075
>
Attempt: newAttempt,
1076
>
AttemptsSinceLastSuccess: newAttemptsSinceLastSuccess,
1077
>
OriginalScheduledTime: time.Unix(0, 0).UTC(),
1078
>
Type: enumsspb.WORKFLOW_TASK_TYPE_UNSPECIFIED,
1079
>
SuggestContinueAsNew: false,
1080
>
SuggestContinueAsNewReasons: nil,
1081
>
HistorySizeBytes: 0,
1082
>
// need to retain Build ID of failed WF task to compare it with the build ID of next attempt
1083
>
BuildId: m.ms.executionInfo.WorkflowTaskBuildId,
1084
>
}
1085
>
m.retainWorkflowTaskBuildIdInfo(failWorkflowTaskInfo)
1086
>
m.UpdateWorkflowTask(failWorkflowTaskInfo)
1087
>
1088
>
consecutiveFailuresRequired := m.ms.config.NumConsecutiveWorkflowTaskProblemsToTriggerSearchAttribute(m.ms.GetNamespaceEntry().Name().String())
1089
>
if consecutiveFailuresRequired > 0 && failWorkflowTaskInfo.AttemptsSinceLastSuccess >= int32(consecutiveFailuresRequired) {
1090
if err := m.ms.UpdateReportedProblemsSearchAttribute(); err != nil {
1091
return err
1092
}
1093
}
1095
}
1096