Skip to content

Commit

Permalink
Improve is cross cluster task check (#4326)
Browse files Browse the repository at this point in the history
  • Loading branch information
yycptt committed Jul 23, 2021
1 parent c75cbf8 commit 54d6ccb
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions service/history/task/transfer_active_task_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ func (t *transferActiveTaskExecutor) processCancelExecution(
return err
}

if targetCluster, isCrossCluster := t.isCrossClusterTask(targetDomainEntry); isCrossCluster {
if targetCluster, isCrossCluster := t.isCrossClusterTask(task.DomainID, targetDomainEntry); isCrossCluster {
return t.generateCrossClusterTask(ctx, wfContext, task, targetCluster)
}

Expand Down Expand Up @@ -509,7 +509,7 @@ func (t *transferActiveTaskExecutor) processSignalExecution(
return err
}

if targetCluster, isCrossCluster := t.isCrossClusterTask(targetDomainEntry); isCrossCluster {
if targetCluster, isCrossCluster := t.isCrossClusterTask(task.DomainID, targetDomainEntry); isCrossCluster {
return t.generateCrossClusterTask(ctx, wfContext, task, targetCluster)
}

Expand Down Expand Up @@ -647,7 +647,7 @@ func (t *transferActiveTaskExecutor) processStartChildExecution(
// it is possible that the domain got deleted. Use domainID instead as this is only needed for the history event
targetDomainName = task.TargetDomainID
} else {
if targetCluster, isCrossCluster := t.isCrossClusterTask(targetDomainEntry); isCrossCluster {
if targetCluster, isCrossCluster := t.isCrossClusterTask(task.DomainID, targetDomainEntry); isCrossCluster {
return t.generateCrossClusterTask(ctx, wfContext, task, targetCluster)
}

Expand Down Expand Up @@ -1196,8 +1196,13 @@ func (t *transferActiveTaskExecutor) signalExternalExecutionFailed(
}

func (t *transferActiveTaskExecutor) isCrossClusterTask(
sourceDomainID string,
targetDomainEntry *cache.DomainCacheEntry,
) (string, bool) {
if sourceDomainID == targetDomainEntry.GetInfo().ID {
return "", false
}

targetCluster := targetDomainEntry.GetReplicationConfig().ActiveClusterName
if targetCluster != t.shard.GetClusterMetadata().GetCurrentClusterName() {
return targetCluster, true
Expand Down

0 comments on commit 54d6ccb

Please sign in to comment.