Skip to content

Commit

Permalink
Improve is cross cluster task check (cadence-workflow#4326)
Browse files Browse the repository at this point in the history
  • Loading branch information
yycptt authored Jul 23, 2021
1 parent 989e35c commit 23eb8be
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"

"github.com/uber/cadence/client/history"
"github.com/uber/cadence/common"
"github.com/uber/cadence/common/cluster"
Expand Down
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 @@ -409,7 +409,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 @@ -630,7 +630,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 @@ -1194,8 +1194,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 23eb8be

Please sign in to comment.