From 4db8d90da3a7ebdf63458afcdb60085760287210 Mon Sep 17 00:00:00 2001 From: Prathyush PV Date: Thu, 16 Jan 2025 10:43:34 -0800 Subject: [PATCH] Return error if workflow backoff timer is not fired (#7095) ## What changed? Return error from task executor if workflow back of timer is not fired. ## Why? To prevent outer layers to count no-op timers as fired. ## How did you test it? Existing unit test ## Potential risks No ## Is hotfix candidate? Yes --- service/history/timer_queue_active_task_executor.go | 12 +++++++++--- .../history/timer_queue_active_task_executor_test.go | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/service/history/timer_queue_active_task_executor.go b/service/history/timer_queue_active_task_executor.go index cdf7d95aa76..e5233c9f630 100644 --- a/service/history/timer_queue_active_task_executor.go +++ b/service/history/timer_queue_active_task_executor.go @@ -447,8 +447,13 @@ func (t *timerQueueActiveTaskExecutor) executeWorkflowBackoffTimerTask( if err != nil { return err } - if mutableState == nil || !mutableState.IsWorkflowExecutionRunning() { - return nil + if mutableState == nil { + release(nil) + return consts.ErrWorkflowExecutionNotFound + } + if !mutableState.IsWorkflowExecutionRunning() { + release(nil) + return consts.ErrWorkflowCompleted } // TODO: deprecated, remove below 3 metrics after v1.25 @@ -477,7 +482,8 @@ func (t *timerQueueActiveTaskExecutor) executeWorkflowBackoffTimerTask( if mutableState.HadOrHasWorkflowTask() { // already has workflow task - return nil + release(nil) + return errNoTimerFired } // schedule first workflow task diff --git a/service/history/timer_queue_active_task_executor_test.go b/service/history/timer_queue_active_task_executor_test.go index f6cd2bbc364..c52c6dfc6b5 100644 --- a/service/history/timer_queue_active_task_executor_test.go +++ b/service/history/timer_queue_active_task_executor_test.go @@ -1279,7 +1279,7 @@ func (s *timerQueueActiveTaskExecutorSuite) TestWorkflowBackoffTimer_Noop() { s.mockExecutionMgr.EXPECT().GetWorkflowExecution(gomock.Any(), gomock.Any()).Return(&persistence.GetWorkflowExecutionResponse{State: persistenceMutableState}, nil) resp := s.timerQueueActiveTaskExecutor.Execute(context.Background(), s.newTaskExecutable(timerTask)) - s.NoError(resp.ExecutionErr) + s.ErrorIs(resp.ExecutionErr, errNoTimerFired) } func (s *timerQueueActiveTaskExecutorSuite) TestActivityRetryTimer_Fire() {