Skip to content

Commit

Permalink
Return error if workflow backoff timer is not fired (#7095)
Browse files Browse the repository at this point in the history
## 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
  • Loading branch information
prathyushpv authored and bergundy committed Jan 16, 2025
1 parent 94a53e7 commit 9f6cc97
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions service/history/timer_queue_active_task_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion service/history/timer_queue_active_task_executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 9f6cc97

Please sign in to comment.