From 827205c133b199d22a5097db6c6c53eb97f2b871 Mon Sep 17 00:00:00 2001 From: Prathyush PV Date: Thu, 16 Jan 2025 10:13:50 -0800 Subject: [PATCH 1/2] Return error if workflow backoff timer is not fired --- service/history/timer_queue_active_task_executor.go | 9 ++++++--- service/history/timer_queue_active_task_executor_test.go | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/service/history/timer_queue_active_task_executor.go b/service/history/timer_queue_active_task_executor.go index 0a268b9c203..c881bd3f481 100644 --- a/service/history/timer_queue_active_task_executor.go +++ b/service/history/timer_queue_active_task_executor.go @@ -446,8 +446,11 @@ func (t *timerQueueActiveTaskExecutor) executeWorkflowBackoffTimerTask( if err != nil { return err } - if mutableState == nil || !mutableState.IsWorkflowExecutionRunning() { - return nil + if mutableState == nil { + return consts.ErrWorkflowExecutionNotFound + } + if !mutableState.IsWorkflowExecutionRunning() { + return consts.ErrWorkflowCompleted } // TODO: deprecated, remove below 3 metrics after v1.25 @@ -476,7 +479,7 @@ func (t *timerQueueActiveTaskExecutor) executeWorkflowBackoffTimerTask( if mutableState.HadOrHasWorkflowTask() { // already has workflow task - return 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 85243a9ba15..30b47fe5fca 100644 --- a/service/history/timer_queue_active_task_executor_test.go +++ b/service/history/timer_queue_active_task_executor_test.go @@ -1303,7 +1303,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() { From 4707ba877e72d1d42edb5cb876a5b966e81c53d5 Mon Sep 17 00:00:00 2001 From: Prathyush PV Date: Thu, 16 Jan 2025 10:19:03 -0800 Subject: [PATCH 2/2] Release with no error --- service/history/timer_queue_active_task_executor.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/service/history/timer_queue_active_task_executor.go b/service/history/timer_queue_active_task_executor.go index c881bd3f481..ff96a90e4ca 100644 --- a/service/history/timer_queue_active_task_executor.go +++ b/service/history/timer_queue_active_task_executor.go @@ -447,9 +447,11 @@ func (t *timerQueueActiveTaskExecutor) executeWorkflowBackoffTimerTask( return err } if mutableState == nil { + release(nil) return consts.ErrWorkflowExecutionNotFound } if !mutableState.IsWorkflowExecutionRunning() { + release(nil) return consts.ErrWorkflowCompleted } @@ -479,6 +481,7 @@ func (t *timerQueueActiveTaskExecutor) executeWorkflowBackoffTimerTask( if mutableState.HadOrHasWorkflowTask() { // already has workflow task + release(nil) return errNoTimerFired }