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

Commit

Permalink
better retry (#3098)
Browse files Browse the repository at this point in the history
  • Loading branch information
Guihao Liang authored Apr 10, 2020
1 parent c9349b3 commit 58a8ea4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/core/storage/fileio/s3_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,9 @@ list_objects_response list_objects_impl(s3url parsed_url, std::string proxy,
break;

} else {
auto error = outcome.GetError().GetResponseCode();
auto error = outcome.GetError();

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

if (n_retry == 3) {
Expand Down
7 changes: 5 additions & 2 deletions src/core/storage/fileio/s3_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,14 @@ std::ostream& reportS3Error(std::ostream& ss, const s3url& parsed_url,
S3Operation::ops_enum operation,
const Aws::Client::ClientConfiguration& config,
const Response& outcome) {
auto error = outcome.GetError();
ss << "('" << parsed_url << ", proxy: '" << config.proxyHost << "', region: '"
<< config.region << "')"
<< " Error while performing " << S3Operation::toString(operation)
<< ". Error Name: " << outcome.GetError().GetExceptionName()
<< ". Error Message: " << outcome.GetError().GetMessage();
<< ". Error Name: " << error.GetExceptionName()
<< ". Error Message: " << error.GetMessage()
<< ". HTTP Error Code: " << static_cast<int>(error.GetResponseCode());

return ss;
}

Expand Down
8 changes: 4 additions & 4 deletions test/fileio/s3_filesys_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ int main(int argc, char** argv) {
// force write all entries
sa_ptr->materialize();

/* teardown manually */
turi::file_download_cache::get_instance().clear();
turi::block_cache::release_instance();

} catch (std::string& e) {
std::cerr << "Exception: " << e << std::endl;
} catch (std::exception& e) {
std::cerr << "Exception: " << e.what() << std::endl;
}

/* teardown manually */
turi::file_download_cache::get_instance().clear();
turi::block_cache::release_instance();

return 0;
}

0 comments on commit 58a8ea4

Please sign in to comment.