Skip to content

Commit

Permalink
Return an empty response when PollWorkflowUpdateRequest times out
Browse files Browse the repository at this point in the history
  • Loading branch information
tdeebswihart committed Sep 25, 2023
1 parent f44307c commit 7b535f2
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
5 changes: 4 additions & 1 deletion service/frontend/workflow_handler.go
Expand Up @@ -3176,7 +3176,10 @@ func (wh *WorkflowHandler) PollWorkflowExecutionUpdate(
Request: request,
},
)
if err != nil {
if errors.Is(err, context.DeadlineExceeded) {
// Return an empty response to match the behaviors of PollWorkflowTaskQueue and PollActivityTaskQueue
return nil, nil
} else if err != nil {
return nil, err
}
return histResp.GetResponse(), nil
Expand Down
49 changes: 49 additions & 0 deletions service/frontend/workflow_handler_test.go
Expand Up @@ -45,6 +45,7 @@ import (
replicationpb "go.temporal.io/api/replication/v1"
"go.temporal.io/api/serviceerror"
taskqueuepb "go.temporal.io/api/taskqueue/v1"
updatepb "go.temporal.io/api/update/v1"
workflowpb "go.temporal.io/api/workflow/v1"
"go.temporal.io/api/workflowservice/v1"
"google.golang.org/grpc"
Expand Down Expand Up @@ -2595,3 +2596,51 @@ func (s *workflowHandlerSuite) Test_DeleteWorkflowExecution() {
s.NoError(err)
s.NotNil(resp)
}

func (s *workflowHandlerSuite) TestPollWorkflowExecutionUpdate_FailWhenDisabled() {
config := s.newConfig()
wh := s.getWorkflowHandler(config)
req := workflowservice.PollWorkflowExecutionUpdateRequest{
Namespace: s.T().Name() + "-ns",
UpdateRef: &updatepb.UpdateRef{
WorkflowExecution: &commonpb.WorkflowExecution{
WorkflowId: s.T().Name() + "-workflow-id",
RunId: s.T().Name() + "-run-id",
},
},
Identity: s.T().Name() + "-ident",
WaitPolicy: nil,
}

s.mockNamespaceCache.EXPECT().GetNamespaceID(gomock.Any()).Return(namespace.ID(s.T().Name()+"-nsid"), nil)

bgCtx := context.Background()
resp, err := wh.PollWorkflowExecutionUpdate(bgCtx, &req)
s.Equal(errUpdateWorkflowExecutionAPINotAllowed, err)
s.Nil(resp)
}

func (s *workflowHandlerSuite) TestPollWorkflowExecutionUpdate_Timeout() {
config := s.newConfig()
config.EnableUpdateWorkflowExecution = dc.GetBoolPropertyFnFilteredByNamespace(true)
wh := s.getWorkflowHandler(config)
req := workflowservice.PollWorkflowExecutionUpdateRequest{
Namespace: s.T().Name() + "-ns",
UpdateRef: &updatepb.UpdateRef{
WorkflowExecution: &commonpb.WorkflowExecution{
WorkflowId: s.T().Name() + "-workflow-id",
RunId: s.T().Name() + "-run-id",
},
},
Identity: s.T().Name() + "-ident",
WaitPolicy: nil,
}

s.mockNamespaceCache.EXPECT().GetNamespaceID(gomock.Any()).Return(namespace.ID(s.T().Name()+"-nsid"), nil)
s.mockHistoryClient.EXPECT().PollWorkflowExecutionUpdate(gomock.Any(), gomock.Any()).Return(nil, context.DeadlineExceeded)

bgCtx := context.Background()
resp, err := wh.PollWorkflowExecutionUpdate(bgCtx, &req)
s.NoError(err)
s.Nil(resp)
}

0 comments on commit 7b535f2

Please sign in to comment.