Skip to content

Commit cfa1fa2

Browse files
committed
Fix NPE in GCP archival (#4626)
1 parent fa97428 commit cfa1fa2

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

common/archiver/gcloud/historyArchiver.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,10 @@ func getNextHistoryBlob(ctx context.Context, historyIterator archiver.HistoryIte
328328
return historyBlob, nil
329329
}
330330

331+
// with XDC(global domain) concept, archival may write different history with the same RunID, with different failoverVersion.
332+
// In that case, the history/runID with the highest failoverVersion wins.
333+
// getHighestVersion look up all archived files to find the highest failoverVersion.
334+
// Since a history is written into different parts in this archival implementation, it also returns the highest and lowest partVersionID.
331335
func (h *historyArchiver) getHighestVersion(ctx context.Context, URI archiver.URI, request *archiver.GetHistoryRequest) (*int64, *int, *int, error) {
332336

333337
filenames, err := h.gcloudStorage.Query(ctx, URI, constructHistoryFilenamePrefix(request.DomainID, request.WorkflowID, request.RunID))
@@ -364,6 +368,9 @@ func (h *historyArchiver) getHighestVersion(ctx context.Context, URI archiver.UR
364368

365369
}
366370

371+
if highestVersion == nil {
372+
return nil, nil, nil, archiver.ErrHistoryNotExist
373+
}
367374
return highestVersion, highestVersionPart, lowestVersionPart, nil
368375
}
369376

common/archiver/s3store/historyArchiver.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,9 @@ func getNextHistoryBlob(ctx context.Context, historyIterator archiver.HistoryIte
373373
return historyBlob, nil
374374
}
375375

376+
// with XDC(global domain) concept, archival may write different history with the same RunID, with different failoverVersion.
377+
// In that case, the history/runID with the highest failoverVersion wins.
378+
// getHighestVersion look up all archived files to find the highest failoverVersion.
376379
func (h *historyArchiver) getHighestVersion(ctx context.Context, URI archiver.URI, request *archiver.GetHistoryRequest) (*int64, error) {
377380
ctx, cancel := ensureContextTimeout(ctx)
378381
defer cancel()

0 commit comments

Comments
 (0)