diff --git a/service/history/replication/executable_sync_versioned_transition_task.go b/service/history/replication/executable_sync_versioned_transition_task.go index 0dccec05f5..071564706e 100644 --- a/service/history/replication/executable_sync_versioned_transition_task.go +++ b/service/history/replication/executable_sync_versioned_transition_task.go @@ -220,6 +220,25 @@ func (e *ExecutableSyncVersionedTransitionTask) HandleErr(err error) error { return err } return e.Execute() + + case *serviceerror.NotFound: + e.Logger.Error( + "workflow not found in source cluster, proceed to cleanup", + tag.WorkflowNamespaceID(e.NamespaceID), + tag.WorkflowID(e.WorkflowID), + tag.WorkflowRunID(e.RunID), + ) + // workflow is not found in source cluster, cleanup workflow in target cluster + ctx, cancel := newTaskContext(e.NamespaceName(), e.Config.ReplicationTaskApplyTimeout(), callerInfo) + defer cancel() + return e.DeleteWorkflow( + ctx, + definition.NewWorkflowKey( + e.NamespaceID, + e.WorkflowID, + e.RunID, + ), + ) default: return err } diff --git a/service/history/replication/executable_verify_versioned_transition_task.go b/service/history/replication/executable_verify_versioned_transition_task.go index d5f18540c4..5e8085f575 100644 --- a/service/history/replication/executable_verify_versioned_transition_task.go +++ b/service/history/replication/executable_verify_versioned_transition_task.go @@ -300,6 +300,25 @@ func (e *ExecutableVerifyVersionedTransitionTask) HandleErr(err error) error { return nil } return e.Execute() + case *serviceerror.NotFound: + e.Logger.Error( + "workflow not found in source cluster, proceed to cleanup", + tag.WorkflowNamespaceID(e.NamespaceID), + tag.WorkflowID(e.WorkflowID), + tag.WorkflowRunID(e.RunID), + ) + callerInfo := getReplicaitonCallerInfo(e.GetPriority()) + // workflow is not found in source cluster, cleanup workflow in target cluster + ctx, cancel := newTaskContext(e.NamespaceName(), e.Config.ReplicationTaskApplyTimeout(), callerInfo) + defer cancel() + return e.DeleteWorkflow( + ctx, + definition.NewWorkflowKey( + e.NamespaceID, + e.WorkflowID, + e.RunID, + ), + ) default: return err }