Skip to content

Commit

Permalink
SNOW-872499: Disable max retries in chunk downloader if maxHttpRetrie…
Browse files Browse the repository at this point in the history
…s is 0 (#1488)

disable max retries in chunk downloader if maxHttpRetries is 0
  • Loading branch information
sfc-gh-ext-simba-lb committed Jul 27, 2023
1 parent a22121e commit 709b4ab
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -636,15 +636,16 @@ public SnowflakeResultChunk getNextChunkToConsume()
private void waitForChunkReady(SnowflakeResultChunk currentChunk) throws InterruptedException {
int retry = 0;
long startTime = System.currentTimeMillis();
while (currentChunk.getDownloadState() != DownloadState.SUCCESS && retry < maxHttpRetries) {
while (true) {
logger.debug(
"Thread {} is waiting for #chunk{} to be ready, current" + "chunk state is: {}, retry={}",
Thread.currentThread().getId(),
nextChunkToConsume,
currentChunk.getDownloadState(),
retry);

if (currentChunk.getDownloadState() != DownloadState.FAILURE) {
if (currentChunk.getDownloadState() != DownloadState.FAILURE
&& currentChunk.getDownloadState() != DownloadState.SUCCESS) {
// if the state is not failure, we should keep waiting; otherwise, we skip
// waiting
if (!currentChunk
Expand All @@ -669,6 +670,7 @@ private void waitForChunkReady(SnowflakeResultChunk currentChunk) throws Interru
}
}

// retry if chunk is not successfully downloaded
if (currentChunk.getDownloadState() != DownloadState.SUCCESS) {
retry++;
// timeout or failed
Expand Down Expand Up @@ -715,6 +717,13 @@ private void waitForChunkReady(SnowflakeResultChunk currentChunk) throws Interru
nextChunkToDownload = nextChunkToConsume + 1;
}
}

// exit if chunk has downloaded or we have hit max retry
// maxHttpRetries = 0 will retry indefinitely
if (currentChunk.getDownloadState() == DownloadState.SUCCESS
|| (maxHttpRetries > 0 && retry >= maxHttpRetries)) {
break;
}
}
if (currentChunk.getDownloadState() == DownloadState.SUCCESS) {
logger.debug("ready to consume #chunk{}, succeed retry={}", nextChunkToConsume, retry);
Expand Down

0 comments on commit 709b4ab

Please sign in to comment.