diff --git a/gpcontrib/gpcloud/include/s3exception.h b/gpcontrib/gpcloud/include/s3exception.h index 37789743df20599b97a6e6ef8ef6eb32b42da8a8..f194983d6b9629f5c6f74ffc5fb18c4d5234c9a2 100644 --- a/gpcontrib/gpcloud/include/s3exception.h +++ b/gpcontrib/gpcloud/include/s3exception.h @@ -13,6 +13,9 @@ class S3Exception { virtual ~S3Exception() { } + virtual string getCode() { + return ""; + } virtual string getMessage() { return ""; } @@ -128,6 +131,10 @@ class S3LogicError : public S3Exception { } virtual ~S3LogicError() { } + virtual string getCode() { + return awscode; + } + virtual string getMessage() { return "AWS returns error " + awscode + " : " + message; } diff --git a/gpcontrib/gpcloud/src/s3interface.cpp b/gpcontrib/gpcloud/src/s3interface.cpp index bd9a05b7c1c096d1d2aebbeb3a634826a2d5f10d..12dff7b2805a3bf2a8a5849e5f350364f9dc3a56 100644 --- a/gpcontrib/gpcloud/src/s3interface.cpp +++ b/gpcontrib/gpcloud/src/s3interface.cpp @@ -31,6 +31,7 @@ S3InterfaceService::~S3InterfaceService() { Response S3InterfaceService::getResponseWithRetries(const string &url, HTTPHeaders &headers, uint64_t retries) { + string code; string message; uint64_t retry = retries; @@ -43,6 +44,14 @@ Response S3InterfaceService::getResponseWithRetries(const string &url, HTTPHeade S3_DIE(S3QueryAbort, "Downloading is interrupted"); } S3WARN("Failed to get a good response in GET from '%s', retrying ...", url.c_str()); + } catch (S3LogicError &e) { + code = e.getCode(); + if (code == "NoSuchKey") { + sleep(1); + continue; + } else { + throw e; + } } };