Skip to content

Commit

Permalink
Enable workflow corruption check for Describe and Query API (cadence-…
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaddoll authored Nov 18, 2022
1 parent 9472846 commit 1a50671
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions service/history/historyEngine.go
Original file line number Diff line number Diff line change
Expand Up @@ -1207,6 +1207,12 @@ func (e *historyEngineImpl) QueryWorkflow(
if err != nil {
return nil, err
}
// If history is corrupted, query will be rejected
if corrupted, err := e.checkForHistoryCorruptions(ctx, mutableState); err != nil {
return nil, err
} else if corrupted {
return nil, &types.EntityNotExistsError{Message: "Workflow execution corrupted."}
}

// There are two ways in which queries get dispatched to decider. First, queries can be dispatched on decision tasks.
// These decision tasks potentially contain new events and queries. The events are treated as coming before the query in time.
Expand Down Expand Up @@ -1579,6 +1585,13 @@ func (e *historyEngineImpl) DescribeWorkflowExecution(
if err1 != nil {
return nil, err1
}
// If history is corrupted, return an error to the end user
if corrupted, err := e.checkForHistoryCorruptions(ctx, mutableState); err != nil {
return nil, err
} else if corrupted {
return nil, &types.EntityNotExistsError{Message: "Workflow execution corrupted."}
}

executionInfo := mutableState.GetExecutionInfo()

result := &types.DescribeWorkflowExecutionResponse{
Expand Down

0 comments on commit 1a50671

Please sign in to comment.