Skip to content

Commit

Permalink
Fix status check for downloads to also include UPLOADED status
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Khare authored and Kartik Khare committed Jan 10, 2025
1 parent f4b1420 commit 81ea9ee
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ public void reloadSegment(String segmentName, IndexLoadingConfig indexLoadingCon
- Continue loading the segment from the index directory.
*/
boolean shouldDownload =
forceDownload || (zkMetadata.getStatus() == CommonConstants.Segment.Realtime.Status.DONE && !hasSameCRC(
forceDownload || (isSegmentStatusCompleted(zkMetadata) && !hasSameCRC(
zkMetadata, localMetadata));
if (shouldDownload) {
// Create backup directory to handle failure of segment reloading.
Expand Down Expand Up @@ -717,6 +717,11 @@ public void reloadSegment(String segmentName, IndexLoadingConfig indexLoadingCon
_logger.info("Reloaded segment: {}", segmentName);
}

private boolean isSegmentStatusCompleted(SegmentZKMetadata zkMetadata) {
return zkMetadata.getStatus() == CommonConstants.Segment.Realtime.Status.DONE
|| zkMetadata.getStatus() == CommonConstants.Segment.Realtime.Status.UPLOADED;
}

private boolean canReuseExistingDirectoryForReload(SegmentZKMetadata segmentZKMetadata, String currentSegmentTier,
SegmentDirectory segmentDirectory, IndexLoadingConfig indexLoadingConfig, Schema schema)
throws Exception {
Expand Down Expand Up @@ -1011,8 +1016,7 @@ public boolean tryLoadExistingSegment(SegmentZKMetadata zkMetadata, IndexLoading
Then:
We need to fall back to downloading the segment from deep storage to load it.
*/
if (segmentMetadata == null || (zkMetadata.getStatus() == CommonConstants.Segment.Realtime.Status.DONE
&& !hasSameCRC(zkMetadata, segmentMetadata))) {
if (segmentMetadata == null || (isSegmentStatusCompleted(zkMetadata) && !hasSameCRC(zkMetadata, segmentMetadata))) {
if (segmentMetadata == null) {
_logger.info("Segment: {} does not exist", segmentName);
} else if (!hasSameCRC(zkMetadata, segmentMetadata)) {
Expand Down

0 comments on commit 81ea9ee

Please sign in to comment.