Skip to content

Commit 3bc8c49

Browse files
parasebacrepererum
authored andcommitted
Retry requests when status code is 429 (apache#410)
This code is what HTTP uses to indicate the client has sent too many requests in a given amount of time. It may sound counter-intuitive to retry in this situation, but that's why we use an exponential backoff mechanism. It gives the server the opportunity to recover, without failing the requests immediately. The retry mechanism already works in object stores like S3 because they return a server error. But without this change, we are not handling GCS properly. GCS returns a client error `429 Too Many Requests` instead. This change enables retries on this response too. A more advanced retry mechanism would use the optional response header `Retry-After`, but that is beyond the scope of this PR. Closes: apache#309
1 parent 9df5965 commit 3bc8c49

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/client/retry.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ impl RetryableRequest {
402402
let status = r.status();
403403
if ctx.exhausted()
404404
|| !(status.is_server_error()
405+
|| status == StatusCode::TOO_MANY_REQUESTS
405406
|| (self.retry_on_conflict && status == StatusCode::CONFLICT))
406407
{
407408
let source = match status.is_client_error() {

0 commit comments

Comments
 (0)