Skip to content

Commit

Permalink
Add special case handling for validate historyV2 continuousness for g…
Browse files Browse the repository at this point in the history
…etting history from remote (cadence-workflow#1670)
  • Loading branch information
longquanzheng authored Apr 8, 2019
1 parent ebdd0b3 commit c55bc43
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions common/persistence/historyV2Store.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ func (m *historyV2ManagerImpl) readHistoryBranch(byBatch bool, request *ReadHist
}
}

token, err := m.pagingTokenSerializer.Deserialize(request.NextPageToken, request.MinEventID-1, common.EmptyVersion)
defaultLastEventID := request.MinEventID - 1
token, err := m.pagingTokenSerializer.Deserialize(request.NextPageToken, defaultLastEventID, common.EmptyVersion)
if err != nil {
return nil, nil, nil, 0, 0, err
}
Expand Down Expand Up @@ -341,9 +342,14 @@ func (m *historyV2ManagerImpl) readHistoryBranch(byBatch bool, request *ReadHist
continue
}
if firstEvent.GetEventId() != token.LastEventID+1 {
logger.Errorf("Corrupted incontinouous event batch, %v, %v, %v, %v, %v, %v", firstEvent.GetVersion(), lastEvent.GetVersion(), firstEvent.GetEventId(), lastEvent.GetEventId(), eventCount, token.LastEventID)
return nil, nil, nil, 0, 0, &workflow.InternalServiceError{
Message: fmt.Sprintf("corrupted history event batch, eventID is not continouous"),
// We assume application layer want to read from MinEventID(inclusive)
// However, for getting history from remote cluster, there is scenario that we have to read from middle without knowing the firstEventID.
// In that case we don't validate history continuousness for the first page
if defaultLastEventID == 0 || token.LastEventID != defaultLastEventID {
logger.Errorf("Corrupted incontinouous event batch, %v, %v, %v, %v, %v, %v", firstEvent.GetVersion(), lastEvent.GetVersion(), firstEvent.GetEventId(), lastEvent.GetEventId(), eventCount, token.LastEventID)
return nil, nil, nil, 0, 0, &workflow.InternalServiceError{
Message: fmt.Sprintf("corrupted history event batch, eventID is not continouous"),
}
}
}

Expand Down

0 comments on commit c55bc43

Please sign in to comment.