aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhiddenpath <hiddenpath@yandex-team.com>2025-01-14 15:22:11 +0300
committerhiddenpath <hiddenpath@yandex-team.com>2025-01-14 15:41:05 +0300
commite6ef3b21f38c311f6b0d6adb666a5d5b2190b32d (patch)
tree51c199c0aba3880f9c7b7747d5f3343162fcc8b0
parent5e54c4796d90907b3ea27c7e0f581a612a529ef2 (diff)
downloadydb-e6ef3b21f38c311f6b0d6adb666a5d5b2190b32d.tar.gz
Remove RetryRequestWithPolicy
commit_hash:c37dfdf6ccb765ed1d799f3a85a419e7ba917c31
-rw-r--r--yt/cpp/mapreduce/http/retry_request.cpp81
-rw-r--r--yt/cpp/mapreduce/http/retry_request.h11
-rw-r--r--yt/cpp/mapreduce/raw_client/raw_requests.cpp13
3 files changed, 12 insertions, 93 deletions
diff --git a/yt/cpp/mapreduce/http/retry_request.cpp b/yt/cpp/mapreduce/http/retry_request.cpp
index a47b2952b1..0f57021cab 100644
--- a/yt/cpp/mapreduce/http/retry_request.cpp
+++ b/yt/cpp/mapreduce/http/retry_request.cpp
@@ -71,87 +71,6 @@ NHttpClient::IHttpResponsePtr RequestWithoutRetry(
return Request(context, header, body, requestId, config);
}
-
-TResponseInfo RetryRequestWithPolicy(
- IRequestRetryPolicyPtr retryPolicy,
- const TClientContext& context,
- THttpHeader& header,
- TMaybe<TStringBuf> body,
- const TRequestConfig& config)
-{
- if (context.ServiceTicketAuth) {
- header.SetServiceTicket(context.ServiceTicketAuth->Ptr->IssueServiceTicket());
- } else {
- header.SetToken(context.Token);
- }
-
- UpdateHeaderForProxyIfNeed(context.ServerName, context, header);
-
- if (context.ImpersonationUser) {
- header.SetImpersonationUser(*context.ImpersonationUser);
- }
-
- bool useMutationId = header.HasMutationId();
- bool retryWithSameMutationId = false;
-
- if (!retryPolicy) {
- retryPolicy = CreateDefaultRequestRetryPolicy(context.Config);
- }
-
- while (true) {
- auto requestId = CreateGuidAsString();
- try {
- retryPolicy->NotifyNewAttempt();
-
- if (useMutationId) {
- if (retryWithSameMutationId) {
- header.AddParameter("retry", true, /* overwrite = */ true);
- } else {
- header.RemoveParameter("retry");
- header.AddMutationId();
- }
- }
-
- auto response = Request(context, header, body, requestId, config);
- return TResponseInfo{
- .RequestId = response->GetRequestId(),
- .Response = response->GetResponse(),
- .HttpCode = response->GetStatusCode(),
- };
- } catch (const TErrorResponse& e) {
- LogRequestError(requestId, header, e.what(), retryPolicy->GetAttemptDescription());
- retryWithSameMutationId = e.IsTransportError();
-
- if (!IsRetriable(e)) {
- throw;
- }
-
- auto maybeRetryTimeout = retryPolicy->OnRetriableError(e);
- if (maybeRetryTimeout) {
- TWaitProxy::Get()->Sleep(*maybeRetryTimeout);
- } else {
- throw;
- }
- } catch (const std::exception& e) {
- LogRequestError(requestId, header, e.what(), retryPolicy->GetAttemptDescription());
- retryWithSameMutationId = true;
-
- if (!IsRetriable(e)) {
- throw;
- }
-
- auto maybeRetryTimeout = retryPolicy->OnGenericError(e);
- if (maybeRetryTimeout) {
- TWaitProxy::Get()->Sleep(*maybeRetryTimeout);
- } else {
- throw;
- }
- }
- }
-
- Y_ABORT("Retries must have either succeeded or thrown an exception");
-}
-
////////////////////////////////////////////////////////////////////////////////
} // namespace NDetail
diff --git a/yt/cpp/mapreduce/http/retry_request.h b/yt/cpp/mapreduce/http/retry_request.h
index 444ecbbafc..88aef52f25 100644
--- a/yt/cpp/mapreduce/http/retry_request.h
+++ b/yt/cpp/mapreduce/http/retry_request.h
@@ -96,21 +96,12 @@ TResult RequestWithRetry(
}
}
-// Retry request with given `header' and `body' using `retryPolicy'.
-// If `retryPolicy == nullptr' use default, currently `TAttemptLimitedRetryPolicy(TConfig::Get()->RetryCount)`.
-TResponseInfo RetryRequestWithPolicy(
- IRequestRetryPolicyPtr retryPolicy,
- const TClientContext& context,
- THttpHeader& header,
- TMaybe<TStringBuf> body = {},
- const TRequestConfig& config = TRequestConfig());
-
NHttpClient::IHttpResponsePtr RequestWithoutRetry(
const TClientContext& context,
TMutationId& mutationId,
THttpHeader& header,
TMaybe<TStringBuf> body = {},
- const TRequestConfig& config = TRequestConfig());
+ const TRequestConfig& config = {});
////////////////////////////////////////////////////////////////////////////////
diff --git a/yt/cpp/mapreduce/raw_client/raw_requests.cpp b/yt/cpp/mapreduce/raw_client/raw_requests.cpp
index 04b5ef5dc0..601fe887b4 100644
--- a/yt/cpp/mapreduce/raw_client/raw_requests.cpp
+++ b/yt/cpp/mapreduce/raw_client/raw_requests.cpp
@@ -64,9 +64,18 @@ void ExecuteBatch(
auto body = NodeToYsonString(parameters);
THttpHeader header("POST", "execute_batch");
header.AddMutationId();
- NDetail::TResponseInfo result;
+ TResponseInfo result;
try {
- result = RetryRequestWithPolicy(retryPolicy, context, header, body);
+ result = RequestWithRetry<TResponseInfo>(
+ retryPolicy,
+ [&context, &header, &body] (TMutationId& mutationId) {
+ auto response = RequestWithoutRetry(context, mutationId, header, body);
+ return TResponseInfo{
+ .RequestId = response->GetRequestId(),
+ .Response = response->GetResponse(),
+ .HttpCode = response->GetStatusCode(),
+ };
+ });
} catch (const std::exception& e) {
batchRequest.SetErrorResult(std::current_exception());
retryBatch.SetErrorResult(std::current_exception());