diff options
author | Alexander Smirnov <alex@ydb.tech> | 2025-02-18 13:35:23 +0000 |
---|---|---|
committer | Alexander Smirnov <alex@ydb.tech> | 2025-02-18 13:35:23 +0000 |
commit | d1f5b91da822b27faad83d50ecfdd2830a1be93e (patch) | |
tree | 78df3bf535cb8a5451afa402c51cb3f8d11b4d06 /yt/cpp | |
parent | 22bc9b81495143d67a93bf58c936c5d5a65c8e8e (diff) | |
parent | a2f16dc9eb108ecf11938c7c4275d701a3635bb7 (diff) | |
download | ydb-d1f5b91da822b27faad83d50ecfdd2830a1be93e.tar.gz |
Merge pull request #14716 from ydb-platform/merge-libs-250218-0050
Diffstat (limited to 'yt/cpp')
-rw-r--r-- | yt/cpp/mapreduce/common/retry_lib.cpp | 11 | ||||
-rw-r--r-- | yt/cpp/mapreduce/http/http.cpp | 11 | ||||
-rw-r--r-- | yt/cpp/mapreduce/http/http_client.cpp | 13 | ||||
-rw-r--r-- | yt/cpp/mapreduce/interface/errors.cpp | 18 | ||||
-rw-r--r-- | yt/cpp/mapreduce/interface/errors.h | 3 |
5 files changed, 39 insertions, 17 deletions
diff --git a/yt/cpp/mapreduce/common/retry_lib.cpp b/yt/cpp/mapreduce/common/retry_lib.cpp index 826247cb57..53216bd3f8 100644 --- a/yt/cpp/mapreduce/common/retry_lib.cpp +++ b/yt/cpp/mapreduce/common/retry_lib.cpp @@ -203,16 +203,11 @@ static bool IsRetriableChunkError(const TSet<int>& codes) static TMaybe<TDuration> TryGetBackoffDuration(const TErrorResponse& errorResponse, const TConfigPtr& config) { - int httpCode = errorResponse.GetHttpCode(); - if (httpCode / 100 != 4 && !errorResponse.IsFromTrailers()) { - return config->RetryInterval; - } - auto allCodes = errorResponse.GetError().GetAllErrorCodes(); using namespace NClusterErrorCodes; - if (httpCode == 429 - || allCodes.count(NSecurityClient::RequestQueueSizeLimitExceeded) - || allCodes.count(NRpc::RequestQueueSizeLimitExceeded)) + + if (allCodes.count(NSecurityClient::RequestQueueSizeLimitExceeded) || + allCodes.count(NRpc::RequestQueueSizeLimitExceeded)) { // request rate limit exceeded return config->RateLimitExceededRetryInterval; diff --git a/yt/cpp/mapreduce/http/http.cpp b/yt/cpp/mapreduce/http/http.cpp index 765a96f042..4bddeab86d 100644 --- a/yt/cpp/mapreduce/http/http.cpp +++ b/yt/cpp/mapreduce/http/http.cpp @@ -768,21 +768,21 @@ THttpResponse::THttpResponse( ErrorResponse_ = TErrorResponse(HttpCode_, Context_.RequestId); - auto logAndSetError = [&] (const TString& rawError) { + auto logAndSetError = [&] (int code, const TString& rawError) { YT_LOG_ERROR("RSP %v - HTTP %v - %v", Context_.RequestId, HttpCode_, rawError.data()); - ErrorResponse_->SetRawError(rawError); + ErrorResponse_->SetError(TYtError(code, rawError)); }; switch (HttpCode_) { case 429: - logAndSetError("request rate limit exceeded"); + logAndSetError(NClusterErrorCodes::NSecurityClient::RequestQueueSizeLimitExceeded, "request rate limit exceeded"); break; case 500: - logAndSetError(::TStringBuilder() << "internal error in proxy " << Context_.HostName); + logAndSetError(NClusterErrorCodes::NRpc::Unavailable, ::TStringBuilder() << "internal error in proxy " << Context_.HostName); break; default: { @@ -803,6 +803,9 @@ THttpResponse::THttpResponse( if (auto parsedResponse = ParseError(HttpInput_->Headers())) { ErrorResponse_ = parsedResponse.GetRef(); + if (HttpCode_ == 503) { + ExtendGenericError(*ErrorResponse_, NClusterErrorCodes::NBus::TransportError, "transport error"); + } } else { ErrorResponse_->SetRawError( errorString + " - X-YT-Error is missing in headers"); diff --git a/yt/cpp/mapreduce/http/http_client.cpp b/yt/cpp/mapreduce/http/http_client.cpp index 7e9d761c3c..34be58daab 100644 --- a/yt/cpp/mapreduce/http/http_client.cpp +++ b/yt/cpp/mapreduce/http/http_client.cpp @@ -7,6 +7,7 @@ #include <yt/cpp/mapreduce/interface/config.h> +#include <yt/cpp/mapreduce/interface/error_codes.h> #include <yt/cpp/mapreduce/interface/logging/yt_log.h> #include <yt/yt/core/concurrency/thread_pool_poller.h> @@ -42,21 +43,22 @@ TMaybe<TErrorResponse> GetErrorResponse(const TString& hostName, const TString& TErrorResponse errorResponse(static_cast<int>(httpCode), requestId); - auto logAndSetError = [&] (const TString& rawError) { + auto logAndSetError = [&] (int code, const TString& rawError) { YT_LOG_ERROR("RSP %v - HTTP %v - %v", requestId, httpCode, rawError.data()); - errorResponse.SetRawError(rawError); + errorResponse.SetError(TYtError(code, rawError)); }; + switch (httpCode) { case NHttp::EStatusCode::TooManyRequests: - logAndSetError("request rate limit exceeded"); + logAndSetError(NClusterErrorCodes::NSecurityClient::RequestQueueSizeLimitExceeded, "request rate limit exceeded"); break; case NHttp::EStatusCode::InternalServerError: - logAndSetError("internal error in proxy " + hostName); + logAndSetError(NClusterErrorCodes::NRpc::Unavailable, "internal error in proxy " + hostName); break; default: { @@ -80,6 +82,9 @@ TMaybe<TErrorResponse> GetErrorResponse(const TString& hostName, const TString& if (errorResponse.IsOk()) { return Nothing(); } + if (httpCode == NHttp::EStatusCode::ServiceUnavailable) { + ExtendGenericError(errorResponse, NClusterErrorCodes::NBus::TransportError, "transport error"); + } return errorResponse; } diff --git a/yt/cpp/mapreduce/interface/errors.cpp b/yt/cpp/mapreduce/interface/errors.cpp index 42c7466dcb..fcc23fb3ac 100644 --- a/yt/cpp/mapreduce/interface/errors.cpp +++ b/yt/cpp/mapreduce/interface/errors.cpp @@ -332,7 +332,7 @@ bool TErrorResponse::IsFromTrailers() const bool TErrorResponse::IsTransportError() const { - return HttpCode_ == 503; + return Error_.ContainsErrorCode(NClusterErrorCodes::NBus::TransportError); } TString TErrorResponse::GetRequestId() const @@ -355,6 +355,22 @@ bool TErrorResponse::IsAccessDenied() const return Error_.ContainsErrorCode(NClusterErrorCodes::NSecurityClient::AuthorizationError); } +bool TErrorResponse::IsUnauthorized() const +{ + const auto allCodes = Error_.GetAllErrorCodes(); + for (auto code : { + NClusterErrorCodes::NRpc::AuthenticationError, + NClusterErrorCodes::NRpc::InvalidCsrfToken, + NClusterErrorCodes::NRpc::InvalidCredentials, + NClusterErrorCodes::NSecurityClient::AuthenticationError, + }) { + if (allCodes.contains(code)) { + return true; + } + } + return false; +} + bool TErrorResponse::IsConcurrentTransactionLockConflict() const { return Error_.ContainsErrorCode(NClusterErrorCodes::NCypressClient::ConcurrentTransactionLockConflict); diff --git a/yt/cpp/mapreduce/interface/errors.h b/yt/cpp/mapreduce/interface/errors.h index 749b294f0f..a008ff07b8 100644 --- a/yt/cpp/mapreduce/interface/errors.h +++ b/yt/cpp/mapreduce/interface/errors.h @@ -182,6 +182,9 @@ public: /// Check if error was caused by lack of permissions to execute request. bool IsAccessDenied() const; + /// Check if error was caused by authorization issues. + bool IsUnauthorized() const; + /// Check if error was caused by failure to lock object because of another transaction is holding lock. bool IsConcurrentTransactionLockConflict() const; |