Skip to content
This repository was archived by the owner on Dec 21, 2023. It is now read-only.

Commit 58a8ea4

Browse files
author
Guihao Liang
authored
better retry (#3098)
1 parent c9349b3 commit 58a8ea4

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

src/core/storage/fileio/s3_api.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,9 @@ list_objects_response list_objects_impl(s3url parsed_url, std::string proxy,
512512
break;
513513

514514
} else {
515-
auto error = outcome.GetError().GetResponseCode();
515+
auto error = outcome.GetError();
516516

517-
if (error == Aws::Http::HttpResponseCode::TOO_MANY_REQUESTS) {
517+
if (error.ShouldRetry()) {
518518
n_retry++;
519519

520520
if (n_retry == 3) {

src/core/storage/fileio/s3_api.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,14 @@ std::ostream& reportS3Error(std::ostream& ss, const s3url& parsed_url,
286286
S3Operation::ops_enum operation,
287287
const Aws::Client::ClientConfiguration& config,
288288
const Response& outcome) {
289+
auto error = outcome.GetError();
289290
ss << "('" << parsed_url << ", proxy: '" << config.proxyHost << "', region: '"
290291
<< config.region << "')"
291292
<< " Error while performing " << S3Operation::toString(operation)
292-
<< ". Error Name: " << outcome.GetError().GetExceptionName()
293-
<< ". Error Message: " << outcome.GetError().GetMessage();
293+
<< ". Error Name: " << error.GetExceptionName()
294+
<< ". Error Message: " << error.GetMessage()
295+
<< ". HTTP Error Code: " << static_cast<int>(error.GetResponseCode());
296+
294297
return ss;
295298
}
296299

test/fileio/s3_filesys_test.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,15 @@ int main(int argc, char** argv) {
9191
// force write all entries
9292
sa_ptr->materialize();
9393

94-
/* teardown manually */
95-
turi::file_download_cache::get_instance().clear();
96-
turi::block_cache::release_instance();
97-
9894
} catch (std::string& e) {
9995
std::cerr << "Exception: " << e << std::endl;
10096
} catch (std::exception& e) {
10197
std::cerr << "Exception: " << e.what() << std::endl;
10298
}
10399

100+
/* teardown manually */
101+
turi::file_download_cache::get_instance().clear();
102+
turi::block_cache::release_instance();
103+
104104
return 0;
105105
}

0 commit comments

Comments
 (0)