You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "Xuanwo (via GitHub)" <gi...@apache.org> on 2023/04/30 13:05:54 UTC

[GitHub] [incubator-opendal] Xuanwo commented on a diff in pull request #2171: fix(service/s3): set retryable on batch

Xuanwo commented on code in PR #2171:
URL: https://github.com/apache/incubator-opendal/pull/2171#discussion_r1181228353


##########
core/src/services/s3/error.rs:
##########
@@ -79,6 +71,34 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>) -> Result<Error> {
     Ok(err)
 }
 
+/// Returns the Errorkind of this code and whether the error is retryable.
+/// All possible error code: <https://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html#ErrorCodeList>
+pub fn kind_and_retryable(code: &str) -> Option<(ErrorKind, bool)> {

Review Comment:
   I prefer to have an API like:
   
   `fn parse_s3_error_code(code: &str) -> (ErrorKind, bool)`



##########
core/src/services/s3/error.rs:
##########
@@ -79,6 +71,34 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>) -> Result<Error> {
     Ok(err)
 }
 
+/// Returns the Errorkind of this code and whether the error is retryable.
+/// All possible error code: <https://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html#ErrorCodeList>
+pub fn kind_and_retryable(code: &str) -> Option<(ErrorKind, bool)> {
+    match code {
+        // > Your socket connection to the server was not read from
+        // > or written to within the timeout period."
+        //
+        // It's Ok for us to retry it again.
+        "RequestTimeout" => Some((ErrorKind::Unexpected, true)),
+        // > An internal error occurred. Try again.
+        "InternalError" => Some((ErrorKind::Unexpected, true)),
+        // > A conflicting conditional operation is currently in progress
+        // > against this resource. Try again.
+        "OperationAborted" => Some((ErrorKind::Unexpected, true)),
+        // > Please reduce your request rate.
+        //
+        // It's Ok to retry since later on the request rate may get reduced.
+        "SlowDown" => Some((ErrorKind::Unexpected, true)),

Review Comment:
   We can use `RateLimited`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org