Skip to content

Commit

Permalink
always increment retry counter in getQueryResultWithRetriesForAsyncMode
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-ext-simba-jl committed Jan 12, 2024
1 parent d3da821 commit 6d54e29
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions async.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ func getQueryResultWithRetriesForAsyncMode(
var respd *execResponse
retry := 0
retryPattern := []int32{1, 1, 2, 3, 4, 8, 10}
retryPatternIndex := 0

for {
logger.WithContext(ctx).Debugf("Retry count for get query result request in async mode: %v", retry)
Expand All @@ -168,12 +169,13 @@ func getQueryResultWithRetriesForAsyncMode(
} else {
// Sleep before retrying get result request. Exponential backoff up to 5 seconds.
// Once 5 second backoff is reached it will keep retrying with this sleeptime.
sleepTime := time.Millisecond * time.Duration(500*retryPattern[retry])
sleepTime := time.Millisecond * time.Duration(500*retryPattern[retryPatternIndex])
logger.WithContext(ctx).Infof("Query execution still in progress. Response code: %v, message: %v Sleep for %v ms", respd.Code, respd.Message, sleepTime)
time.Sleep(sleepTime)
retry++

if retry < len(retryPattern)-1 {
retry++
if retryPatternIndex < len(retryPattern)-1 {
retryPatternIndex++
}
}
}
Expand Down

0 comments on commit 6d54e29

Please sign in to comment.