Skip to content

Commit

Permalink
Handle reset workflow with pending child wf (#2624)
Browse files Browse the repository at this point in the history
  • Loading branch information
yux0 authored Mar 22, 2022
1 parent f7ed394 commit 856089a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
13 changes: 10 additions & 3 deletions service/history/historyEngine.go
Original file line number Diff line number Diff line change
Expand Up @@ -3230,7 +3230,7 @@ func (e *historyEngineImpl) ReapplyEvents(
// TODO when https://github.com/uber/cadence/issues/2420 is finished, remove this block,
// since cannot reapply event to a finished workflow which had no workflow tasks started
if baseRebuildLastEventID == common.EmptyEventID {
e.logger.Warn("cannot reapply event to a finished workflow",
e.logger.Warn("cannot reapply event to a finished workflow with no workflow task",
tag.WorkflowNamespaceID(namespaceID.String()),
tag.WorkflowID(currentExecution.GetWorkflowId()),
)
Expand All @@ -3253,7 +3253,7 @@ func (e *historyEngineImpl) ReapplyEvents(
baseCurrentBranchToken := baseCurrentVersionHistory.GetBranchToken()
baseNextEventID := mutableState.GetNextEventID()

if err = e.workflowResetter.resetWorkflow(
err = e.workflowResetter.resetWorkflow(
ctx,
namespaceID,
workflowID,
Expand All @@ -3275,7 +3275,14 @@ func (e *historyEngineImpl) ReapplyEvents(
eventsReapplicationResetWorkflowReason,
toReapplyEvents,
enumspb.RESET_REAPPLY_TYPE_SIGNAL,
); err != nil {
)
switch err.(type) {
case *serviceerror.InvalidArgument:
// no-op. Usually this is due to reset workflow with pending child workflows
e.logger.Warn("Cannot reset workflow. Ignoring reapply events.", tag.Error(err))
case nil:
//no-op
default:
return nil, err
}
return &updateWorkflowAction{
Expand Down
14 changes: 11 additions & 3 deletions service/history/nDCTransactionMgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ import (
"context"
"time"

"go.temporal.io/server/common"

"go.temporal.io/server/common/persistence/serialization"

"github.com/pborman/uuid"
commonpb "go.temporal.io/api/common/v1"
enumspb "go.temporal.io/api/enums/v1"
"go.temporal.io/api/serviceerror"

"go.temporal.io/server/common"
"go.temporal.io/server/common/cluster"
"go.temporal.io/server/common/log"
"go.temporal.io/server/common/log/tag"
Expand Down Expand Up @@ -346,7 +347,7 @@ func (r *nDCTransactionMgrImpl) backfillWorkflowEventsReapply(
baseCurrentBranchToken := baseCurrentVersionHistory.GetBranchToken()
baseNextEventID := baseMutableState.GetNextEventID()

if err = r.workflowResetter.resetWorkflow(
err = r.workflowResetter.resetWorkflow(
ctx,
namespaceID,
workflowID,
Expand All @@ -361,7 +362,14 @@ func (r *nDCTransactionMgrImpl) backfillWorkflowEventsReapply(
eventsReapplicationResetWorkflowReason,
targetWorkflowEvents.Events,
enumspb.RESET_REAPPLY_TYPE_SIGNAL,
); err != nil {
)
switch err.(type) {
case *serviceerror.InvalidArgument:
// no-op. Usually this is due to reset workflow with pending child workflows
r.logger.Warn("Cannot reset workflow. Ignoring reapply events.", tag.Error(err))
case nil:
//no-op
default:
return 0, workflow.TransactionPolicyActive, err
}
// after the reset of target workflow (current workflow) with additional events to be reapplied
Expand Down

0 comments on commit 856089a

Please sign in to comment.