From df66d346dfc3c1d1136256ea58d0419d12599a50 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 21 Feb 2017 11:42:38 +0100 Subject: [PATCH] Log AWS retries --- src/libstore/s3-binary-cache-store.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/libstore/s3-binary-cache-store.cc b/src/libstore/s3-binary-cache-store.cc index ac083410b..041c68c68 100644 --- a/src/libstore/s3-binary-cache-store.cc +++ b/src/libstore/s3-binary-cache-store.cc @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -57,12 +58,25 @@ S3Helper::S3Helper() { } +/* Log AWS retries. */ +class RetryStrategy : public Aws::Client::DefaultRetryStrategy +{ + long CalculateDelayBeforeNextRetry(const Aws::Client::AWSError& error, long attemptedRetries) const override + { + auto res = Aws::Client::DefaultRetryStrategy::CalculateDelayBeforeNextRetry(error, attemptedRetries); + printError("AWS error '%s' (%s), will retry in %d ms", + error.GetExceptionName(), error.GetMessage(), res); + return res; + } +}; + ref S3Helper::makeConfig() { initAWS(); auto res = make_ref(); res->region = Aws::Region::US_EAST_1; // FIXME: make configurable res->requestTimeoutMs = 600 * 1000; + res->retryStrategy = std::make_shared(); return res; }