Skip to content

Commit 856089a

Browse files
authored
Handle reset workflow with pending child wf (#2624)
1 parent f7ed394 commit 856089a

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

service/history/historyEngine.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3230,7 +3230,7 @@ func (e *historyEngineImpl) ReapplyEvents(
32303230
// TODO when https://github.com/uber/cadence/issues/2420 is finished, remove this block,
32313231
// since cannot reapply event to a finished workflow which had no workflow tasks started
32323232
if baseRebuildLastEventID == common.EmptyEventID {
3233-
e.logger.Warn("cannot reapply event to a finished workflow",
3233+
e.logger.Warn("cannot reapply event to a finished workflow with no workflow task",
32343234
tag.WorkflowNamespaceID(namespaceID.String()),
32353235
tag.WorkflowID(currentExecution.GetWorkflowId()),
32363236
)
@@ -3253,7 +3253,7 @@ func (e *historyEngineImpl) ReapplyEvents(
32533253
baseCurrentBranchToken := baseCurrentVersionHistory.GetBranchToken()
32543254
baseNextEventID := mutableState.GetNextEventID()
32553255

3256-
if err = e.workflowResetter.resetWorkflow(
3256+
err = e.workflowResetter.resetWorkflow(
32573257
ctx,
32583258
namespaceID,
32593259
workflowID,
@@ -3275,7 +3275,14 @@ func (e *historyEngineImpl) ReapplyEvents(
32753275
eventsReapplicationResetWorkflowReason,
32763276
toReapplyEvents,
32773277
enumspb.RESET_REAPPLY_TYPE_SIGNAL,
3278-
); err != nil {
3278+
)
3279+
switch err.(type) {
3280+
case *serviceerror.InvalidArgument:
3281+
// no-op. Usually this is due to reset workflow with pending child workflows
3282+
e.logger.Warn("Cannot reset workflow. Ignoring reapply events.", tag.Error(err))
3283+
case nil:
3284+
//no-op
3285+
default:
32793286
return nil, err
32803287
}
32813288
return &updateWorkflowAction{

service/history/nDCTransactionMgr.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@ import (
3030
"context"
3131
"time"
3232

33+
"go.temporal.io/server/common"
34+
3335
"go.temporal.io/server/common/persistence/serialization"
3436

3537
"github.com/pborman/uuid"
3638
commonpb "go.temporal.io/api/common/v1"
3739
enumspb "go.temporal.io/api/enums/v1"
3840
"go.temporal.io/api/serviceerror"
3941

40-
"go.temporal.io/server/common"
4142
"go.temporal.io/server/common/cluster"
4243
"go.temporal.io/server/common/log"
4344
"go.temporal.io/server/common/log/tag"
@@ -346,7 +347,7 @@ func (r *nDCTransactionMgrImpl) backfillWorkflowEventsReapply(
346347
baseCurrentBranchToken := baseCurrentVersionHistory.GetBranchToken()
347348
baseNextEventID := baseMutableState.GetNextEventID()
348349

349-
if err = r.workflowResetter.resetWorkflow(
350+
err = r.workflowResetter.resetWorkflow(
350351
ctx,
351352
namespaceID,
352353
workflowID,
@@ -361,7 +362,14 @@ func (r *nDCTransactionMgrImpl) backfillWorkflowEventsReapply(
361362
eventsReapplicationResetWorkflowReason,
362363
targetWorkflowEvents.Events,
363364
enumspb.RESET_REAPPLY_TYPE_SIGNAL,
364-
); err != nil {
365+
)
366+
switch err.(type) {
367+
case *serviceerror.InvalidArgument:
368+
// no-op. Usually this is due to reset workflow with pending child workflows
369+
r.logger.Warn("Cannot reset workflow. Ignoring reapply events.", tag.Error(err))
370+
case nil:
371+
//no-op
372+
default:
365373
return 0, workflow.TransactionPolicyActive, err
366374
}
367375
// after the reset of target workflow (current workflow) with additional events to be reapplied

0 commit comments

Comments
 (0)