Skip to content

Commit 719b499

Browse files
committed
Regroup curl code lists
1 parent 087b82f commit 719b499

File tree

5 files changed

+46
-30
lines changed

5 files changed

+46
-30
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(NYql::THttpRetryPolicyOptions{.MaxTime = TDuration::Max(), .ExtendedRetriedCodes = {CURLE_GOT_NOTHING}});
198+
auto s3HttpRetryPolicy = NYql::GetHTTPDefaultRetryPolicy(NYql::THttpRetryPolicyOptions{.MaxTime = TDuration::Max(), .RetriedCurlCodes = NYql::FqRetriedCurlCodes()});
199199
NYql::NDq::TS3ReadActorFactoryConfig readActorFactoryCfg;
200200
if (const ui64 rowsInBatch = s3readConfig.GetRowsInBatch()) {
201201
readActorFactoryCfg.RowsInBatch = rowsInBatch;

ydb/core/kqp/compute_actor/kqp_compute_actor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ NYql::NDq::IDqAsyncIoFactory::TPtr CreateKqpAsyncIoFactory(
7777
RegisterSequencerActorFactory(*factory, counters);
7878

7979
if (federatedQuerySetup) {
80-
auto s3HttpRetryPolicy = NYql::GetHTTPDefaultRetryPolicy(NYql::THttpRetryPolicyOptions{.ExtendedRetriedCodes = {CURLE_GOT_NOTHING}});
80+
auto s3HttpRetryPolicy = NYql::GetHTTPDefaultRetryPolicy(NYql::THttpRetryPolicyOptions{.RetriedCurlCodes = NYql::FqRetriedCurlCodes()});
8181
RegisterS3ReadActorFactory(*factory, federatedQuerySetup->CredentialsFactory, federatedQuerySetup->HttpGateway, s3HttpRetryPolicy);
8282
RegisterS3WriteActorFactory(*factory, federatedQuerySetup->CredentialsFactory, federatedQuerySetup->HttpGateway, s3HttpRetryPolicy);
8383

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

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,50 @@
22

33
namespace NYql {
44

5+
std::unordered_set<CURLcode> YqlRetriedCurlCodes() {
6+
return {
7+
CURLE_COULDNT_CONNECT,
8+
CURLE_WEIRD_SERVER_REPLY,
9+
CURLE_WRITE_ERROR,
10+
CURLE_READ_ERROR,
11+
CURLE_OPERATION_TIMEDOUT,
12+
CURLE_SSL_CONNECT_ERROR,
13+
CURLE_BAD_DOWNLOAD_RESUME,
14+
CURLE_SEND_ERROR,
15+
CURLE_RECV_ERROR,
16+
CURLE_NO_CONNECTION_AVAILABLE
17+
};
18+
}
19+
20+
std::unordered_set<CURLcode> FqRetriedCurlCodes() {
21+
return {
22+
CURLE_COULDNT_CONNECT,
23+
CURLE_WEIRD_SERVER_REPLY,
24+
CURLE_WRITE_ERROR,
25+
CURLE_READ_ERROR,
26+
CURLE_OPERATION_TIMEDOUT,
27+
CURLE_SSL_CONNECT_ERROR,
28+
CURLE_BAD_DOWNLOAD_RESUME,
29+
CURLE_SEND_ERROR,
30+
CURLE_RECV_ERROR,
31+
CURLE_NO_CONNECTION_AVAILABLE,
32+
CURLE_GOT_NOTHING
33+
};
34+
}
35+
536
IHTTPGateway::TRetryPolicy::TPtr GetHTTPDefaultRetryPolicy(THttpRetryPolicyOptions&& options) {
637
auto maxTime = options.MaxTime;
738
auto maxRetries = options.MaxRetries;
839
if (!maxTime) {
940
maxTime = TDuration::Minutes(5);
1041
}
1142
return IHTTPGateway::TRetryPolicy::GetExponentialBackoffPolicy([options = std::move(options)](CURLcode curlCode, long httpCode) {
12-
13-
switch (curlCode) {
14-
case CURLE_OK:
15-
// look to http code
16-
break;
17-
case CURLE_COULDNT_CONNECT:
18-
case CURLE_WEIRD_SERVER_REPLY:
19-
case CURLE_WRITE_ERROR:
20-
case CURLE_READ_ERROR:
21-
case CURLE_OPERATION_TIMEDOUT:
22-
case CURLE_SSL_CONNECT_ERROR:
23-
case CURLE_BAD_DOWNLOAD_RESUME:
24-
case CURLE_SEND_ERROR:
25-
case CURLE_RECV_ERROR:
26-
case CURLE_NO_CONNECTION_AVAILABLE:
27-
// retry small number of known errors
28-
return ERetryErrorClass::ShortRetry;
29-
default:
30-
if (options.ExtendedRetriedCodes.contains(curlCode)) {
31-
// retry explicitly enumerated codes
32-
return ERetryErrorClass::ShortRetry;
33-
}
34-
// do not retry others
35-
return ERetryErrorClass::NoRetry;
43+
if (curlCode == CURLE_OK) {
44+
// pass
45+
} else if (options.RetriedCurlCodes.contains(curlCode)) {
46+
return ERetryErrorClass::ShortRetry;
47+
} else {
48+
return ERetryErrorClass::NoRetry;
3649
}
3750

3851
switch (httpCode) {

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@
77

88
namespace NYql {
99

10+
std::unordered_set<CURLcode> YqlRetriedCurlCodes();
11+
std::unordered_set<CURLcode> FqRetriedCurlCodes();
12+
1013
struct THttpRetryPolicyOptions {
1114
TDuration MaxTime = TDuration::Zero(); // Zero means default maxTime
1215
size_t MaxRetries = std::numeric_limits<size_t>::max();
13-
std::unordered_set<CURLcode> ExtendedRetriedCodes;
16+
std::unordered_set<CURLcode> RetriedCurlCodes = YqlRetriedCurlCodes();
1417
};
1518

16-
IHTTPGateway::TRetryPolicy::TPtr GetHTTPDefaultRetryPolicy(THttpRetryPolicyOptions&& options);
19+
IHTTPGateway::TRetryPolicy::TPtr GetHTTPDefaultRetryPolicy(THttpRetryPolicyOptions&& options = {});
1720

18-
IHTTPGateway::TRetryPolicy::TPtr GetHTTPDefaultRetryPolicy(TDuration maxTime = TDuration::Zero(), size_t maxRetries = std::numeric_limits<size_t>::max()); // Zero means default maxTime
21+
IHTTPGateway::TRetryPolicy::TPtr GetHTTPDefaultRetryPolicy(TDuration maxTime, size_t maxRetries = std::numeric_limits<size_t>::max()); // Zero means default maxTime
1922

2023
}

ydb/library/yql/providers/s3/actors/yql_s3_applicator_actor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ class TS3ApplicatorActor : public NActors::TActorBootstrapped<TS3ApplicatorActor
231231
, CredentialsFactory(credentialsFactory)
232232
, ExternalEffect(externalEffect)
233233
, ActorSystem(NActors::TActivationContext::ActorSystem())
234-
, RetryPolicy(NYql::GetHTTPDefaultRetryPolicy(NYql::THttpRetryPolicyOptions{.MaxRetries = 3, .ExtendedRetriedCodes = {CURLE_GOT_NOTHING}}))
234+
, RetryPolicy(NYql::GetHTTPDefaultRetryPolicy(NYql::THttpRetryPolicyOptions{.MaxRetries = 3, .RetriedCurlCodes = NYql::FqRetriedCurlCodes()}))
235235
, RetryCount(GLOBAL_RETRY_LIMIT) {
236236
// ^^^ 3 retries in HTTP GW per operation
237237
// up to 100 retries at app level for all operations ^^^

0 commit comments

Comments
 (0)