Skip to content

Commit

Permalink
Only load complete event if need to report to parent (#3207)
Browse files Browse the repository at this point in the history
  • Loading branch information
yiminc authored Aug 10, 2022
1 parent 42168bf commit 9be1e18
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions service/history/transferQueueActiveTaskExecutor.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,16 @@ func (t *transferQueueActiveTaskExecutor) processCloseExecution(
}
executionInfo := mutableState.GetExecutionInfo()
executionState := mutableState.GetExecutionState()
completionEvent, err := mutableState.GetCompletionEvent(ctx)
if err != nil {
return err
var completionEvent *historypb.HistoryEvent // needed to report close event to parent workflow
replyToParentWorkflow := mutableState.HasParentExecution() && executionInfo.NewExecutionRunId == ""
if replyToParentWorkflow {
// only load close event if needed.
completionEvent, err = mutableState.GetCompletionEvent(ctx)
if err != nil {
return err
}
replyToParentWorkflow = replyToParentWorkflow && !IsTerminatedByResetter(completionEvent)
}
replyToParentWorkflow := mutableState.HasParentExecution() && executionInfo.NewExecutionRunId == "" && !IsTerminatedByResetter(completionEvent)
parentNamespaceID := executionInfo.ParentNamespaceId
parentWorkflowID := executionInfo.ParentWorkflowId
parentRunID := executionInfo.ParentRunId
Expand All @@ -323,7 +328,11 @@ func (t *transferQueueActiveTaskExecutor) processCloseExecution(
}

workflowTypeName := executionInfo.WorkflowTypeName
workflowCloseTime := timestamp.TimeValue(completionEvent.GetEventTime())
workflowCloseTime, err := mutableState.GetWorkflowCloseTime(ctx)
if err != nil {
return err
}

workflowStatus := executionState.Status
workflowHistoryLength := mutableState.GetNextEventID() - 1

Expand All @@ -347,7 +356,7 @@ func (t *transferQueueActiveTaskExecutor) processCloseExecution(
workflowTypeName,
workflowStartTime,
workflowExecutionTime,
workflowCloseTime,
*workflowCloseTime,
workflowStatus,
workflowHistoryLength,
visibilityMemo,
Expand Down

0 comments on commit 9be1e18

Please sign in to comment.