Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filter to not reapply event with the same version #3114

Merged
merged 3 commits into from
Mar 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions service/history/historyEngine.go
Original file line number Diff line number Diff line change
Expand Up @@ -2897,6 +2897,29 @@ func (e *historyEngineImpl) ReapplyEvents(
domainID,
currentExecution,
func(context workflowExecutionContext, mutableState mutableState) (*updateWorkflowAction, error) {
// Filter out reapply event from the same cluster
toReapplyEvents := make([]*workflow.HistoryEvent, len(reapplyEvents))
lastWriteVersion, err := mutableState.GetLastWriteVersion()
if err != nil {
return nil, err
}
for _, event := range reapplyEvents {
if event.GetVersion() == lastWriteVersion {
// The reapply is from the same cluster. Ignoring.
continue
}
dedupResource := definition.NewEventReappliedID(runID, event.GetEventId(), event.GetVersion())
if mutableState.IsResourceDuplicated(dedupResource) {
// already apply the signal
continue
}
toReapplyEvents = append(toReapplyEvents, event)
}
if len(toReapplyEvents) == 0 {
return &updateWorkflowAction{
noop: true,
}, nil
}

if !mutableState.IsWorkflowExecutionRunning() {
// need to reset target workflow (which is also the current workflow)
Expand Down Expand Up @@ -2948,7 +2971,7 @@ func (e *historyEngineImpl) ReapplyEvents(
noopReleaseFn,
),
eventsReapplicationResetWorkflowReason,
reapplyEvents,
toReapplyEvents,
); err != nil {
return nil, err
}
Expand All @@ -2967,7 +2990,7 @@ func (e *historyEngineImpl) ReapplyEvents(
reappliedEvents, err := e.eventsReapplier.reapplyEvents(
ctx,
mutableState,
reapplyEvents,
toReapplyEvents,
runID,
)
if err != nil {
Expand Down