Skip to content

Commit

Permalink
YQ-2898 fix query failed with unknown uncommitted upload issue (ydb-p…
Browse files Browse the repository at this point in the history
  • Loading branch information
GrigoriyPA authored and EgorkaZ committed Apr 5, 2024
1 parent dcad5e3 commit 14c13a0
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions ydb/library/yql/providers/s3/actors/yql_s3_applicator_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ class TS3ApplicatorActor;
using TObjectStorageRequest = std::function<void(TS3ApplicatorActor& actor)>;

class TS3ApplicatorActor : public NActors::TActorBootstrapped<TS3ApplicatorActor> {
static constexpr ui64 GLOBAL_RETRY_LIMIT = 100;

public:
using NActors::TActorBootstrapped<TS3ApplicatorActor>::Send;

Expand All @@ -230,7 +232,7 @@ class TS3ApplicatorActor : public NActors::TActorBootstrapped<TS3ApplicatorActor
, ExternalEffect(externalEffect)
, ActorSystem(NActors::TActivationContext::ActorSystem())
, RetryPolicy(NYql::GetHTTPDefaultRetryPolicy(TDuration::Zero(), 3))
, RetryCount(100) {
, RetryCount(GLOBAL_RETRY_LIMIT) {
// ^^^ 3 retries in HTTP GW per operation
// up to 100 retries at app level for all operations ^^^
}
Expand Down Expand Up @@ -271,12 +273,15 @@ class TS3ApplicatorActor : public NActors::TActorBootstrapped<TS3ApplicatorActor
hFunc(TEvPrivate::TEvListParts, Handle);
)

bool RetryOperation(CURLcode curlResponseCode, ui32 httpResponseCode) {
bool RetryOperation(CURLcode curlResponseCode, ui32 httpResponseCode, const TString& url, const TString& operationName) {
auto result = RetryCount && RetryPolicy->CreateRetryState()->GetNextRetryDelay(curlResponseCode, httpResponseCode);
Issues.AddIssue(TStringBuilder() << "Retry operation " << operationName << ", curl error: " << curl_easy_strerror(curlResponseCode) << ", http code: " << httpResponseCode << ", url: " << url);
if (result) {
RetryCount--;
} else {
Finish(true);
Finish(true, RetryCount
? TString("Number of retries exceeded limit per operation")
: TStringBuilder() << "Number of retries exceeded global limit in " << GLOBAL_RETRY_LIMIT << " retries");
}
return result;
}
Expand Down Expand Up @@ -370,8 +375,9 @@ class TS3ApplicatorActor : public NActors::TActorBootstrapped<TS3ApplicatorActor
return;
}
}
LOG_D("CommitMultipartUpload ERROR " << ev->Get()->State->BuildUrl());
if (RetryOperation(result.CurlResponseCode, result.Content.HttpResponseCode)) {
const TString& url = ev->Get()->State->BuildUrl();
LOG_D("CommitMultipartUpload ERROR " << url);
if (RetryOperation(result.CurlResponseCode, result.Content.HttpResponseCode, url, "CommitMultipartUpload")) {
PushCommitMultipartUpload(ev->Get()->State);
}
}
Expand Down Expand Up @@ -444,8 +450,9 @@ class TS3ApplicatorActor : public NActors::TActorBootstrapped<TS3ApplicatorActor
}
return;
}
LOG_D("ListMultipartUploads ERROR " << ev->Get()->State->BuildUrl());
if (RetryOperation(result.CurlResponseCode, result.Content.HttpResponseCode)) {
const TString& url = ev->Get()->State->BuildUrl();
LOG_D("ListMultipartUploads ERROR " << url);
if (RetryOperation(result.CurlResponseCode, result.Content.HttpResponseCode, url, "ListMultipartUploads")) {
PushListMultipartUploads(ev->Get()->State);
}
}
Expand All @@ -467,8 +474,9 @@ class TS3ApplicatorActor : public NActors::TActorBootstrapped<TS3ApplicatorActor
return;
}
}
LOG_D("AbortMultipartUpload ERROR " << ev->Get()->State->BuildUrl());
if (RetryOperation(result.CurlResponseCode, result.Content.HttpResponseCode)) {
const TString& url = ev->Get()->State->BuildUrl();
LOG_D("AbortMultipartUpload ERROR " << url);
if (RetryOperation(result.CurlResponseCode, result.Content.HttpResponseCode, url, "AbortMultipartUpload")) {
PushAbortMultipartUpload(ev->Get()->State);
}
}
Expand Down Expand Up @@ -507,8 +515,9 @@ class TS3ApplicatorActor : public NActors::TActorBootstrapped<TS3ApplicatorActor
}
return;
}
LOG_D("ListParts ERROR " << ev->Get()->State->BuildUrl());
if (RetryOperation(result.CurlResponseCode, result.Content.HttpResponseCode)) {
const TString& url = ev->Get()->State->BuildUrl();
LOG_D("ListParts ERROR " << url);
if (RetryOperation(result.CurlResponseCode, result.Content.HttpResponseCode, url, "ListParts")) {
PushListParts(ev->Get()->State);
}
}
Expand Down

0 comments on commit 14c13a0

Please sign in to comment.