diff --git a/client/clientBean.go b/client/clientBean.go index 014d2a509fd..d2f919a8639 100644 --- a/client/clientBean.go +++ b/client/clientBean.go @@ -191,7 +191,7 @@ func (h *clientBeanImpl) GetRemoteAdminClient(cluster string) (adminservice.Admi if !ok { clusterInfo, clusterFound := h.clusterMetadata.GetAllClusterInfo()[cluster] if !clusterFound { - return nil, &serviceerror.Unavailable{ + return nil, &serviceerror.NotFound{ Message: fmt.Sprintf( "Unknown cluster name: %v with given cluster information map: %v.", cluster, @@ -233,7 +233,7 @@ func (h *clientBeanImpl) GetRemoteFrontendClient(cluster string) (workflowservic if !ok { clusterInfo, clusterFound := h.clusterMetadata.GetAllClusterInfo()[cluster] if !clusterFound { - return nil, &serviceerror.Unavailable{ + return nil, &serviceerror.NotFound{ Message: fmt.Sprintf( "Unknown cluster name: %v with given cluster information map: %v.", cluster, diff --git a/service/history/replication/task_executor.go b/service/history/replication/task_executor.go index 87d7b3577e6..376744a33dc 100644 --- a/service/history/replication/task_executor.go +++ b/service/history/replication/task_executor.go @@ -326,6 +326,10 @@ func (e *taskExecutorImpl) filterTask( namespaceEntry, err := e.namespaceRegistry.GetNamespaceByID(namespaceID) if err != nil { + if _, ok := err.(*serviceerror.NamespaceNotFound); ok { + // Drop the task + return false, nil + } return false, err } diff --git a/service/history/replication/task_executor_test.go b/service/history/replication/task_executor_test.go index 76adbc4930d..cbffe6b98dd 100644 --- a/service/history/replication/task_executor_test.go +++ b/service/history/replication/task_executor_test.go @@ -34,6 +34,7 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" commonpb "go.temporal.io/api/common/v1" + "go.temporal.io/api/serviceerror" enumsspb "go.temporal.io/server/api/enums/v1" historyspb "go.temporal.io/server/api/history/v1" @@ -181,6 +182,16 @@ func (s *taskExecutorSuite) TestFilterTask_EnforceApply() { s.True(ok) } +func (s *taskExecutorSuite) TestFilterTask_NamespaceNotFound() { + namespaceID := namespace.ID(uuid.New()) + s.mockNamespaceCache.EXPECT(). + GetNamespaceByID(namespaceID). + Return(nil, &serviceerror.NamespaceNotFound{}) + ok, err := s.replicationTaskExecutor.filterTask(namespaceID, false) + s.NoError(err) + s.False(ok) +} + func (s *taskExecutorSuite) TestProcessTaskOnce_SyncActivityReplicationTask() { namespaceID := namespace.ID(uuid.New()) workflowID := uuid.New()