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

Properly dedup signal request ID #1558

Merged
merged 2 commits into from
May 20, 2021
Merged
Changes from 1 commit
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
35 changes: 18 additions & 17 deletions service/history/historyEngine.go
Original file line number Diff line number Diff line change
Expand Up @@ -1830,21 +1830,24 @@ func (e *historyEngineImpl) SignalWorkflowExecution(
namespaceID,
execution,
func(context workflowExecutionContext, mutableState mutableState) (*updateWorkflowAction, error) {
executionInfo := mutableState.GetExecutionInfo()
createWorkflowTask := true
// Do not create workflow task when the workflow is cron and the cron has not been started yet
if mutableState.GetExecutionInfo().CronSchedule != "" && !mutableState.HasProcessedOrPendingWorkflowTask() {
createWorkflowTask = false
}
postActions := &updateWorkflowAction{
noop: false,
createWorkflowTask: createWorkflowTask,
if request.GetRequestId() != "" && mutableState.IsSignalRequested(request.GetRequestId()) {
return &updateWorkflowAction{
noop: true,
createWorkflowTask: false,
}, nil
}

if !mutableState.IsWorkflowExecutionRunning() {
return nil, ErrWorkflowCompleted
}

executionInfo := mutableState.GetExecutionInfo()
createWorkflowTask := true
// Do not create workflow task when the workflow is cron and the cron has not been started yet
if executionInfo.CronSchedule != "" && !mutableState.HasProcessedOrPendingWorkflowTask() {
createWorkflowTask = false
}

maxAllowedSignals := e.config.MaximumSignalsPerExecution(namespaceEntry.GetInfo().Name)
if maxAllowedSignals > 0 && int(executionInfo.SignalCount) >= maxAllowedSignals {
e.logger.Info("Execution limit reached for maximum signals", tag.WorkflowSignalCount(executionInfo.SignalCount),
Expand All @@ -1863,22 +1866,20 @@ func (e *historyEngineImpl) SignalWorkflowExecution(
}
}

// deduplicate by request id for signal workflow task
if requestID := request.GetRequestId(); requestID != "" {
if mutableState.IsSignalRequested(requestID) {
return postActions, nil
}
mutableState.AddSignalRequested(requestID)
if request.GetRequestId() != "" {
mutableState.AddSignalRequested(request.GetRequestId())
}

if _, err := mutableState.AddWorkflowExecutionSignaled(
request.GetSignalName(),
request.GetInput(),
request.GetIdentity()); err != nil {
return nil, serviceerror.NewInternal("Unable to signal workflow execution.")
}

return postActions, nil
return &updateWorkflowAction{
noop: false,
createWorkflowTask: createWorkflowTask,
}, nil
})
}

Expand Down