diff --git a/service/history/task/transfer_active_task_executor.go b/service/history/task/transfer_active_task_executor.go index ba63c5a6655..b4413fb51e3 100644 --- a/service/history/task/transfer_active_task_executor.go +++ b/service/history/task/transfer_active_task_executor.go @@ -1818,7 +1818,10 @@ func (t *transferActiveTaskExecutor) applyParentClosePolicyDomainActiveCheck( sameClusterChildDomainIDs := make(map[int64]string) // child init eventID -> child domainID remoteClusters := make(map[string]map[string]struct{}) parentClosePolicyWorkerEnabled := t.shard.GetConfig().EnableParentClosePolicyWorker() - if parentClosePolicyWorkerEnabled && len(childInfos) >= t.shard.GetConfig().ParentClosePolicyThreshold(domainName) { + if parentClosePolicyWorkerEnabled && + len(childInfos) >= t.shard.GetConfig().ParentClosePolicyThreshold(domainName) { + // only signal parent close policy workflow when # of child workflow exceeds threshold + // the system workflow can handle the case where child domain is active in a different cluster return nil, nil, true, nil } @@ -1852,19 +1855,14 @@ func (t *transferActiveTaskExecutor) applyParentClosePolicyDomainActiveCheck( } generators := []generatorF{} - if !parentClosePolicyWorkerEnabled { - for remoteCluster, targetDomainIDs := range remoteClusters { - generators = append( - generators, - func(taskGenerator execution.MutableStateTaskGenerator) error { - return taskGenerator.GenerateCrossClusterApplyParentClosePolicyTask(task, remoteCluster, targetDomainIDs) - }) - } - return generators, sameClusterChildDomainIDs, false, nil + for remoteCluster, targetDomainIDs := range remoteClusters { + generators = append( + generators, + func(taskGenerator execution.MutableStateTaskGenerator) error { + return taskGenerator.GenerateCrossClusterApplyParentClosePolicyTask(task, remoteCluster, targetDomainIDs) + }) } - // if enabled, those cross cluster children will be handled by system workflow - - return generators, sameClusterChildDomainIDs, len(remoteClusters) != 0, nil + return generators, sameClusterChildDomainIDs, false, nil } func (t *transferActiveTaskExecutor) processParentClosePolicy( diff --git a/service/history/task/transfer_active_task_executor_test.go b/service/history/task/transfer_active_task_executor_test.go index f24bf5f2a4c..1ab4d85f355 100644 --- a/service/history/task/transfer_active_task_executor_test.go +++ b/service/history/task/transfer_active_task_executor_test.go @@ -606,7 +606,7 @@ func (s *transferActiveTaskExecutorSuite) TestApplyParentPolicy_SameClusterChild ) } -func (s *transferActiveTaskExecutorSuite) TestApplyParentPolicy_CrossClusterChild_Abandon() { +func (s *transferActiveTaskExecutorSuite) TestApplyParentPolicy_CrossClusterAbandonedChild_Abandon() { s.testProcessCloseExecutionNoParentHasFewChildren( map[string]string{ "child_abandon": s.remoteTargetDomainName, @@ -614,15 +614,6 @@ func (s *transferActiveTaskExecutorSuite) TestApplyParentPolicy_CrossClusterChil "child_cancel": s.domainName, }, func() { - // s.mockParentClosePolicyClient.On("SendParentClosePolicyRequest", mock.Anything, mock.MatchedBy( - // func(request parentclosepolicy.Request) bool { - // fmt.Println(request.Executions) - // return len(request.Executions) == 3 - // }, - // )).Return(nil).Times(1) - // TODO: uncomment the following and remove ParentClosePolicyClient mock after - // cross cluster apply parent close task is fixed - // s.expectCrossClusterApplyParentPolicyCalls() s.expectCancelRequest(s.domainName) s.expectTerminateRequest(s.domainName) }, @@ -637,15 +628,8 @@ func (s *transferActiveTaskExecutorSuite) TestApplyParentPolicy_CrossClusterChil "child_cancel": s.childDomainName, }, func() { - s.mockParentClosePolicyClient.On("SendParentClosePolicyRequest", mock.Anything, mock.MatchedBy( - func(request parentclosepolicy.Request) bool { - return len(request.Executions) == 2 - }, - )).Return(nil).Times(1) - // TODO: uncomment the following and remove ParentClosePolicyClient mock after - // cross cluster apply parent close task is fixed - // s.expectCrossClusterApplyParentPolicyCalls() - // s.expectCancelRequest(s.childDomainName) + s.expectCrossClusterApplyParentPolicyCalls() + s.expectCancelRequest(s.childDomainName) }, ) } @@ -658,15 +642,8 @@ func (s *transferActiveTaskExecutorSuite) TestApplyParentPolicy_CrossClusterChil "child_cancel": s.remoteTargetDomainName, }, func() { - s.mockParentClosePolicyClient.On("SendParentClosePolicyRequest", mock.Anything, mock.MatchedBy( - func(request parentclosepolicy.Request) bool { - return len(request.Executions) == 2 - }, - )).Return(nil).Times(1) - // TODO: uncomment the following and remove ParentClosePolicyClient mock after - // cross cluster apply parent close task is fixed - // s.expectCrossClusterApplyParentPolicyCalls() - // s.expectTerminateRequest(s.domainName) + s.expectCrossClusterApplyParentPolicyCalls() + s.expectTerminateRequest(s.domainName) }, ) } @@ -679,14 +656,7 @@ func (s *transferActiveTaskExecutorSuite) TestApplyParentPolicy_CrossClusterChil "child_cancel": s.remoteTargetDomainName, }, func() { - s.mockParentClosePolicyClient.On("SendParentClosePolicyRequest", mock.Anything, mock.MatchedBy( - func(request parentclosepolicy.Request) bool { - return len(request.Executions) == 2 - }, - )).Return(nil).Times(1) - // TODO: uncomment the following and remove ParentClosePolicyClient mock after - // cross cluster apply parent close task is fixed - // s.expectCrossClusterApplyParentPolicyCalls() + s.expectCrossClusterApplyParentPolicyCalls() }, ) }