Continue to delete workflow execution if namespace is deleted
@@ -836,14 +836,22 @@ func (s *ContextImpl) DeleteWorkflowExecution(
// Do not get namespace cache within shard lock.
namespaceEntry, err := s.GetNamespaceRegistry().GetNamespaceByID(namespace.ID(key.NamespaceID))
+ deleteVisibilityRecord := true
if err != nil {
+ if _, isNotFound := err.(*serviceerror.NotFound); isNotFound {
+ // If namespace is not found, skip visibility record delete but proceed with other deletions.
+ // This case might happen during namespace deletion.
+ deleteVisibilityRecord = false
+ } else {
return err
}
+ }
s.wLock()
defer s.wUnlock()
// Step 1. Delete visibility.
+ if deleteVisibilityRecord {
addTasksRequest := &persistence.AddHistoryTasksRequest{
ShardID: s.shardID,
NamespaceID: key.NamespaceID,
@@ -866,6 +874,7 @@ func (s *ContextImpl) DeleteWorkflowExecution(
if err != nil {
return err
}
+ }
// Step 2. Delete current workflow execution pointer.
delCurRequest := &persistence.DeleteCurrentWorkflowExecutionRequest{
