Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tests for task/task_util.go #6362

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 0 additions & 84 deletions service/history/task/task_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,42 +199,6 @@ func GetTimerTaskMetricScope(
}
}

// getCrossClusterTaskMetricsScope returns the metrics scope index for cross cluster task
func getCrossClusterTaskMetricsScope(
taskType int,
isSource bool,
) int {
switch taskType {
case persistence.CrossClusterTaskTypeStartChildExecution:
if isSource {
return metrics.CrossClusterSourceTaskStartChildExecutionScope
}
return metrics.CrossClusterTargetTaskStartChildExecutionScope
case persistence.CrossClusterTaskTypeCancelExecution:
if isSource {
return metrics.CrossClusterSourceTaskCancelExecutionScope
}
return metrics.CrossClusterTargetTaskCancelExecutionScope
case persistence.CrossClusterTaskTypeSignalExecution:
if isSource {
return metrics.CrossClusterSourceTaskSignalExecutionScope
}
return metrics.CrossClusterTargetTaskSignalExecutionScope
case persistence.CrossClusterTaskTypeRecordChildExeuctionCompleted:
if isSource {
return metrics.CrossClusterSourceTaskRecordChildWorkflowExecutionCompleteScope
}
return metrics.CrossClusterTargetTaskRecordChildWorkflowExecutionCompleteScope
case persistence.CrossClusterTaskTypeApplyParentClosePolicy:
if isSource {
return metrics.CrossClusterSourceTaskApplyParentClosePolicyScope
}
return metrics.CrossClusterTargetTaskApplyParentClosePolicyScope
default:
return metrics.CrossClusterQueueProcessorScope
}
}

// verifyTaskVersion, will return true if failover version check is successful
func verifyTaskVersion(
shard shard.Context,
Expand Down Expand Up @@ -371,54 +335,6 @@ func loadMutableStateForTransferTask(
return msBuilder, nil
}

// load mutable state, if mutable state's next event ID <= task ID, will attempt to refresh
// if still mutable state's next event ID <= task ID, will return nil, nil
// TODO: refactor loadMutableStateForXXXTask function implementation to avoid duplication
func loadMutableStateForCrossClusterTask(
ctx context.Context,
wfContext execution.Context,
crossClusterTask *persistence.CrossClusterTaskInfo,
metricsClient metrics.Client,
logger log.Logger,
) (execution.MutableState, error) {

msBuilder, err := wfContext.LoadWorkflowExecution(ctx)
if err != nil {
if _, ok := err.(*types.EntityNotExistsError); ok {
// this could happen if this is a duplicate processing of the task, and the execution has already completed.
return nil, nil
}
return nil, err
}

if crossClusterTask.ScheduleID >= msBuilder.GetNextEventID() {
metricsClient.IncCounter(metrics.CrossClusterQueueProcessorScope, metrics.StaleMutableStateCounter)
wfContext.Clear()

msBuilder, err = wfContext.LoadWorkflowExecution(ctx)
if err != nil {
return nil, err
}
// after refresh, still mutable state's next event ID <= task ID
if crossClusterTask.ScheduleID >= msBuilder.GetNextEventID() {
domainName := msBuilder.GetDomainEntry().GetInfo().Name
metricsClient.Scope(metrics.CrossClusterQueueProcessorScope, metrics.DomainTag(domainName)).IncCounter(metrics.DataInconsistentCounter)
logger.Error("Cross Cluster Task Processor: task event ID >= MS NextEventID, skip.",
tag.WorkflowDomainName(domainName),
tag.WorkflowDomainID(crossClusterTask.DomainID),
tag.WorkflowID(crossClusterTask.WorkflowID),
tag.WorkflowRunID(crossClusterTask.RunID),
tag.TaskType(crossClusterTask.TaskType),
tag.TaskID(crossClusterTask.TaskID),
tag.WorkflowScheduleID(crossClusterTask.ScheduleID),
tag.WorkflowNextEventID(msBuilder.GetNextEventID()),
)
return nil, nil
}
}
return msBuilder, nil
}

func timeoutWorkflow(
mutableState execution.MutableState,
eventBatchFirstEventID int64,
Expand Down
Loading
Loading