Merge pull request #949 from gaul/503-slow-down

Implement exponential backoff for 503
This commit is contained in:
Takeshi Nakatani 2019-02-03 15:19:28 +09:00 committed by GitHub
commit c04e8e7a9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2104,7 +2104,7 @@ int S3fsCurl::RequestPerform()
}
// 1 attempt + retries...
for(int retrycnt = S3fsCurl::retries; 0 < retrycnt; retrycnt--){
for(int retrycnt = 0; retrycnt < S3fsCurl::retries; ++retrycnt){
// Requests
CURLcode curlCode = curl_easy_perform(hCurl);
@ -2120,11 +2120,6 @@ int S3fsCurl::RequestPerform()
S3FS_PRN_INFO3("HTTP response code %ld", LastResponseCode);
return 0;
}
if(500 <= LastResponseCode){
S3FS_PRN_ERR("HTTP response code = %ld Body Text: %s", LastResponseCode, (bodydata ? bodydata->str() : ""));
sleep(4);
break;
}
// Service response codes which are >= 300 && < 500
switch(LastResponseCode){
@ -2147,6 +2142,17 @@ int S3fsCurl::RequestPerform()
S3FS_PRN_DBG("Body Text: %s", (bodydata ? bodydata->str() : ""));
return -ENOENT;
case 501:
S3FS_PRN_INFO3("HTTP response code 501 was returned, returning ENOTSUP");
S3FS_PRN_DBG("Body Text: %s", (bodydata ? bodydata->str() : ""));
return -ENOTSUP;
case 503:
S3FS_PRN_INFO3("HTTP response code 503 was returned, slowing down");
S3FS_PRN_DBG("Body Text: %s", (bodydata ? bodydata->str() : ""));
sleep(4 << retry_count);
break;
default:
S3FS_PRN_ERR("HTTP response code %ld, returning EIO. Body Text: %s", LastResponseCode, (bodydata ? bodydata->str() : ""));
return -EIO;