From e022877a8a6f0f5986c281461a55e9e7abd7d735 Mon Sep 17 00:00:00 2001 From: Rodrigo Zhou Date: Tue, 3 Oct 2023 15:35:41 -0500 Subject: [PATCH] Refresh upsert visibility task only for running workflows (#4909) **What changed?** Only refresh upsert visibility task for running workflows. **Why?** This can cause out of order visibility tasks to be refreshed (CLOSE task followed by UPSERT task). **How did you test it?** **Potential risks** **Is hotfix candidate?** --- service/history/workflow/task_refresher.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/service/history/workflow/task_refresher.go b/service/history/workflow/task_refresher.go index f48228541bd..1cf0dbafd25 100644 --- a/service/history/workflow/task_refresher.go +++ b/service/history/workflow/task_refresher.go @@ -148,7 +148,7 @@ func (r *TaskRefresherImpl) RefreshTasks( return err } - return r.refreshTasksForWorkflowSearchAttr(taskGenerator) + return r.refreshTasksForWorkflowSearchAttr(mutableState, taskGenerator) } func (r *TaskRefresherImpl) refreshTasksForWorkflowStart( @@ -408,8 +408,11 @@ func (r *TaskRefresherImpl) refreshTasksForSignalExternalWorkflow( } func (r *TaskRefresherImpl) refreshTasksForWorkflowSearchAttr( + mutableState MutableState, taskGenerator TaskGenerator, ) error { - - return taskGenerator.GenerateUpsertVisibilityTask() + if mutableState.GetExecutionState().Status == enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING { + return taskGenerator.GenerateUpsertVisibilityTask() + } + return nil }