Skip to content

Commit

Permalink
Treat WorkflowExecutionAlreadyStartedError as non-transient error (ub…
Browse files Browse the repository at this point in the history
…er#1812)

Setting the WorkflowIDReusePolicy to
'WorkflowIDReusePolicyAllowDuplicateFailedOnly' or
'WorkflowIDReusePolicyRejectDuplicate' results in
'WorkflowExecutionAlreadyStartedError' on StartWorkflowExecution or
SignalWithStartWorkflowExecution. Since this error is treated as
retryable error it results in frontend to keep on retrying the call
until timeout.
  • Loading branch information
samarabbas authored and venkat1109 committed May 8, 2019
1 parent 0de78ac commit f9285c8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions common/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ func IsServiceNonRetryableError(err error) bool {
return true
case *workflow.DomainNotActiveError:
return true
case *workflow.WorkflowExecutionAlreadyStartedError:
return true
case *workflow.CancellationAlreadyRequestedError:
return true
case *yarpcerrors.Status:
Expand Down
10 changes: 7 additions & 3 deletions host/signalworkflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package host

import (
"bytes"
"context"
"encoding/binary"
"strconv"
"strings"
Expand Down Expand Up @@ -1421,23 +1422,26 @@ func (s *integrationSuite) TestSignalWithStartWorkflow_IDReusePolicy() {
Identity: common.StringPtr(identity),
WorkflowIdReusePolicy: &wfIDReusePolicy,
}
resp, err := s.engine.SignalWithStartWorkflowExecution(createContext(), sRequest)
ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
resp, err := s.engine.SignalWithStartWorkflowExecution(ctx, sRequest)
s.Nil(resp)
s.Error(err)
errMsg := err.(*workflow.WorkflowExecutionAlreadyStartedError).GetMessage()
s.True(strings.Contains(errMsg, "reject duplicate workflow ID"))

// test policy WorkflowIdReusePolicyAllowDuplicateFailedOnly
wfIDReusePolicy = workflow.WorkflowIdReusePolicyAllowDuplicateFailedOnly
resp, err = s.engine.SignalWithStartWorkflowExecution(createContext(), sRequest)
ctx, _ = context.WithTimeout(context.Background(), 5*time.Second)
resp, err = s.engine.SignalWithStartWorkflowExecution(ctx, sRequest)
s.Nil(resp)
s.Error(err)
errMsg = err.(*workflow.WorkflowExecutionAlreadyStartedError).GetMessage()
s.True(strings.Contains(errMsg, "allow duplicate workflow ID if last run failed"))

// test policy WorkflowIdReusePolicyAllowDuplicate
wfIDReusePolicy = workflow.WorkflowIdReusePolicyAllowDuplicate
resp, err = s.engine.SignalWithStartWorkflowExecution(createContext(), sRequest)
ctx, _ = context.WithTimeout(context.Background(), 5*time.Second)
resp, err = s.engine.SignalWithStartWorkflowExecution(ctx, sRequest)
s.Nil(err)
s.NotEmpty(resp.GetRunId())

Expand Down

0 comments on commit f9285c8

Please sign in to comment.