Skip to content

Commit

Permalink
Fixing bug where throttled retry's math was off
Browse files Browse the repository at this point in the history
  • Loading branch information
xibz committed Nov 19, 2017
1 parent 14a64cf commit d194ab1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
### SDK Enhancements

### SDK Bugs
* `aws/client`: Retry delays for throttled exception were not limited to 5 mintues (([#1654](https://github.com/aws/aws-sdk-go/pull/1654))
* Fixes [#1653]((https://github.com/aws/aws-sdk-go/issues/1653))
6 changes: 3 additions & 3 deletions aws/client/default_retryer.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ func (d DefaultRetryer) RetryRules(r *request.Request) time.Duration {
}

retryCount := r.RetryCount
if retryCount > 13 {
retryCount = 13
} else if throttle && retryCount > 8 {
if throttle && retryCount > 8 {
retryCount = 8
} else if retryCount > 13 {
retryCount = 13
}

delay := (1 << uint(retryCount)) * (seededRand.Intn(minTime) + minTime)
Expand Down
23 changes: 23 additions & 0 deletions aws/client/default_retryer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,26 @@ func TestGetRetryDelay(t *testing.T) {
}
}
}

func TestRetryDelay(t *testing.T) {
r := request.Request{}
for i := 0; i < 100; i++ {
rTemp := r
rTemp.HTTPResponse = &http.Response{StatusCode: 500, Header: http.Header{"Retry-After": []string{""}}}
rTemp.RetryCount = i
a, _ := getRetryDelay(&rTemp)
if a > 5*time.Minute {
t.Errorf("retry delay should never be greater than five minutes, received %d", a)
}
}

for i := 0; i < 100; i++ {
rTemp := r
rTemp.RetryCount = i
rTemp.HTTPResponse = &http.Response{StatusCode: 503, Header: http.Header{"Retry-After": []string{""}}}
a, _ := getRetryDelay(&rTemp)
if a > 5*time.Minute {
t.Errorf("retry delay should never be greater than five minutes, received %d", a)
}
}
}

0 comments on commit d194ab1

Please sign in to comment.