Skip to content

Commit c860fd8

Browse files
authored
Merge 8b04c1e into d332d4f
2 parents d332d4f + 8b04c1e commit c860fd8

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

ydb/core/fq/libs/init/init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ void Init(
195195

196196
if (protoConfig.GetPrivateApi().GetEnabled()) {
197197
const auto& s3readConfig = protoConfig.GetReadActorsFactoryConfig().GetS3ReadActorFactoryConfig();
198-
auto s3HttpRetryPolicy = NYql::GetHTTPDefaultRetryPolicy(TDuration::Max());
198+
auto s3HttpRetryPolicy = NYql::GetHTTPDefaultRetryPolicy(NYql::THttpRetryPolicyOptions{.MaxTime = TDuration::Max(), .ExtendedRetriedCodes = {CURLE_GOT_NOTHING}});
199199
NYql::NDq::TS3ReadActorFactoryConfig readActorFactoryCfg;
200200
if (const ui64 rowsInBatch = s3readConfig.GetRowsInBatch()) {
201201
readActorFactoryCfg.RowsInBatch = rowsInBatch;

ydb/library/yql/providers/common/http_gateway/yql_http_default_retry_policy.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
namespace NYql {
44

5-
IHTTPGateway::TRetryPolicy::TPtr GetHTTPDefaultRetryPolicy(TDuration maxTime, size_t maxRetries) {
6-
if (!maxTime) {
7-
maxTime = TDuration::Minutes(5);
5+
IHTTPGateway::TRetryPolicy::TPtr GetHTTPDefaultRetryPolicy(THttpRetryPolicyOptions&& options) {
6+
if (!options.MaxTime) {
7+
options.MaxTime = TDuration::Minutes(5);
88
}
9-
return IHTTPGateway::TRetryPolicy::GetExponentialBackoffPolicy([](CURLcode curlCode, long httpCode) {
9+
return IHTTPGateway::TRetryPolicy::GetExponentialBackoffPolicy([options](CURLcode curlCode, long httpCode) {
1010

1111
switch (curlCode) {
1212
case CURLE_OK:
@@ -25,6 +25,10 @@ IHTTPGateway::TRetryPolicy::TPtr GetHTTPDefaultRetryPolicy(TDuration maxTime, si
2525
// retry small number of known errors
2626
return ERetryErrorClass::ShortRetry;
2727
default:
28+
if (options.ExtendedRetriedCodes.contains(curlCode)) {
29+
// retry explicitly enumerated codes
30+
return ERetryErrorClass::ShortRetry;
31+
}
2832
// do not retry others
2933
return ERetryErrorClass::NoRetry;
3034
}
@@ -48,8 +52,12 @@ IHTTPGateway::TRetryPolicy::TPtr GetHTTPDefaultRetryPolicy(TDuration maxTime, si
4852
TDuration::MilliSeconds(10), // minDelay
4953
TDuration::MilliSeconds(200), // minLongRetryDelay
5054
TDuration::Seconds(30), // maxDelay
51-
maxRetries, // maxRetries
52-
maxTime); // maxTime
55+
options.MaxRetries, // maxRetries
56+
options.MaxTime); // maxTime
57+
}
58+
59+
IHTTPGateway::TRetryPolicy::TPtr GetHTTPDefaultRetryPolicy(TDuration maxTime, size_t maxRetries) {
60+
return GetHTTPDefaultRetryPolicy(THttpRetryPolicyOptions{.MaxTime = maxTime, .MaxRetries = maxRetries});
5361
}
5462

5563
}

ydb/library/yql/providers/common/http_gateway/yql_http_default_retry_policy.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,19 @@
22

33
#include "yql_http_gateway.h"
44

5+
#include <curl/curl.h>
6+
#include <unordered_set>
7+
58
namespace NYql {
69

10+
struct THttpRetryPolicyOptions {
11+
TDuration MaxTime = TDuration::Zero(); // Zero means default maxTime
12+
size_t MaxRetries = std::numeric_limits<size_t>::max();
13+
std::unordered_set<CURLcode> ExtendedRetriedCodes;
14+
};
15+
16+
IHTTPGateway::TRetryPolicy::TPtr GetHTTPDefaultRetryPolicy(THttpRetryPolicyOptions&& options);
17+
718
IHTTPGateway::TRetryPolicy::TPtr GetHTTPDefaultRetryPolicy(TDuration maxTime = TDuration::Zero(), size_t maxRetries = std::numeric_limits<size_t>::max()); // Zero means default maxTime
819

920
}

0 commit comments

Comments
 (0)