aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorilnaz <ilnaz@ydb.tech>2023-06-19 18:34:26 +0300
committerilnaz <ilnaz@ydb.tech>2023-06-19 18:34:26 +0300
commit678c7b97bbdf46b0485494bd21d9b0bc19e9cdff (patch)
treee711f6d406876da3c55b110a63dc0a37cd1536a2
parent4ce153903b476c0e5eb23709bd56fccd08b2796b (diff)
downloadydb-678c7b97bbdf46b0485494bd21d9b0bc19e9cdff.tar.gz
Retry Complete & Abort multipart upload
-rw-r--r--ydb/core/tx/datashard/export_s3_base_uploader.h50
1 files changed, 35 insertions, 15 deletions
diff --git a/ydb/core/tx/datashard/export_s3_base_uploader.h b/ydb/core/tx/datashard/export_s3_base_uploader.h
index e0f5f9f1b5..66461a3925 100644
--- a/ydb/core/tx/datashard/export_s3_base_uploader.h
+++ b/ydb/core/tx/datashard/export_s3_base_uploader.h
@@ -269,14 +269,21 @@ protected:
<< ": self# " << this->SelfId()
<< ", result# " << result);
- if (!result.IsSuccess()) {
- const auto& error = result.GetError();
- if (error.GetErrorType() != Aws::S3::S3Errors::NO_SUCH_UPLOAD) {
- Error = error.GetMessage().c_str();
- }
+ if (result.IsSuccess()) {
+ return PassAway();
+ }
+
+ const auto& error = result.GetError();
+ if (error.GetErrorType() == Aws::S3::S3Errors::NO_SUCH_UPLOAD) {
+ return PassAway();
}
- PassAway();
+ if (CanRetry(error)) {
+ Retry();
+ } else {
+ Error = error.GetMessage().c_str();
+ PassAway();
+ }
}
void Handle(TEvExternalStorage::TEvAbortMultipartUploadResponse::TPtr& ev) {
@@ -286,13 +293,19 @@ protected:
<< ": self# " << this->SelfId()
<< ", result# " << result);
- if (!result.IsSuccess()) {
+ if (result.IsSuccess()) {
+ return PassAway();
+ }
+
+ const auto& error = result.GetError();
+ if (CanRetry(error)) {
+ Retry();
+ } else {
Y_VERIFY(Error);
Error = TStringBuilder() << *Error << " Additionally, 'AbortMultipartUpload' has failed: "
- << result.GetError().GetMessage();
+ << error.GetMessage();
+ PassAway();
}
-
- PassAway();
}
template <typename TResult>
@@ -321,12 +334,19 @@ protected:
return false;
}
- void RetryOrFinish(const Aws::S3::S3Error& error) {
- if (Attempt++ < Retries && ShouldRetry(error)) {
- Delay = Min(Delay * Attempt, TDuration::Minutes(10));
- const TDuration random = TDuration::FromValue(TAppData::RandomProvider->GenRand64() % Delay.MicroSeconds());
+ bool CanRetry(const Aws::S3::S3Error& error) const {
+ return Attempt < Retries && ShouldRetry(error);
+ }
- this->Schedule(Delay + random, new TEvents::TEvWakeup());
+ void Retry() {
+ Delay = Min(Delay * ++Attempt, TDuration::Minutes(10));
+ const TDuration random = TDuration::FromValue(TAppData::RandomProvider->GenRand64() % Delay.MicroSeconds());
+ this->Schedule(Delay + random, new TEvents::TEvWakeup());
+ }
+
+ void RetryOrFinish(const Aws::S3::S3Error& error) {
+ if (CanRetry(error)) {
+ Retry();
} else {
Finish(false, TStringBuilder() << "S3 error: " << error.GetMessage().c_str());
}