Skip to content

Commit cc38aef

Browse files
[fix](cloud) Fix aws sdk default retry policy not taking effect (apache#43575)
* AWS SDK default retry policy check response xml `code` to determine retry or not, but other object storage such as `OSS`, `COS` not compatible with AWS S3, so adding a custome retry policy for solving the problem
1 parent 19ab0c2 commit cc38aef

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

be/src/util/s3_util.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "common/config.h"
4343
#include "common/logging.h"
4444
#include "common/status.h"
45+
#include "cpp/obj_retry_strategy.h"
4546
#include "cpp/sync_point.h"
4647
#ifdef USE_AZURE
4748
#include "io/fs/azure_obj_storage_client.h"
@@ -307,8 +308,8 @@ std::shared_ptr<io::ObjStorageClient> S3ClientFactory::_create_s3_client(
307308
aws_config.scheme = Aws::Http::Scheme::HTTP;
308309
}
309310

310-
aws_config.retryStrategy =
311-
std::make_shared<Aws::Client::DefaultRetryStrategy>(config::max_s3_client_retry);
311+
aws_config.retryStrategy = std::make_shared<S3CustomRetryStrategy>(
312+
config::max_s3_client_retry /*scaleFactor = 25*/);
312313
std::shared_ptr<Aws::S3::S3Client> new_client;
313314
if (!s3_conf.ak.empty() && !s3_conf.sk.empty()) {
314315
Aws::Auth::AWSCredentials aws_cred(s3_conf.ak, s3_conf.sk);

common/cpp/obj_retry_strategy.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include "obj_retry_strategy.h"
1919

20+
#include <aws/core/http/HttpResponse.h>
2021
#include <bvar/reducer.h>
2122

2223
namespace doris {
@@ -29,12 +30,16 @@ S3CustomRetryStrategy::~S3CustomRetryStrategy() = default;
2930

3031
bool S3CustomRetryStrategy::ShouldRetry(const Aws::Client::AWSError<Aws::Client::CoreErrors>& error,
3132
long attemptedRetries) const {
32-
if (attemptedRetries < m_maxRetries &&
33-
error.GetResponseCode() == Aws::Http::HttpResponseCode::TOO_MANY_REQUESTS) {
33+
if (attemptedRetries >= m_maxRetries) {
34+
return false;
35+
}
36+
37+
if (Aws::Http::IsRetryableHttpResponseCode(error.GetResponseCode()) || error.ShouldRetry()) {
3438
s3_too_many_request_retry_cnt << 1;
3539
return true;
3640
}
37-
return Aws::Client::DefaultRetryStrategy::ShouldRetry(error, attemptedRetries);
41+
42+
return false;
3843
}
3944
#ifdef USE_AZURE
4045
AzureRetryRecordPolicy::AzureRetryRecordPolicy(int retry_cnt) : retry_cnt(retry_cnt) {}

0 commit comments

Comments
 (0)