Skip to content

Commit

Permalink
restrict cases where a retry happens
Browse files Browse the repository at this point in the history
  • Loading branch information
kindly committed Apr 26, 2023
1 parent cc40e22 commit b68d675
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion object_store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ walkdir = "2"

# Cloud storage support
base64 = { version = "0.21", default-features = false, features = ["std"], optional = true }
hyper = { version = "0.14", default-features = false, optional = true }
quick-xml = { version = "0.28.0", features = ["serialize"], optional = true }
serde = { version = "1.0", default-features = false, features = ["derive"], optional = true }
serde_json = { version = "1.0", default-features = false, optional = true }
Expand All @@ -66,7 +67,7 @@ tokio = { version = "1.25.0", features = ["sync", "macros", "rt", "time", "io-ut
nix = "0.26.1"

[features]
cloud = ["serde", "serde_json", "quick-xml", "reqwest", "reqwest/json", "reqwest/stream", "chrono/serde", "base64", "rand", "ring"]
cloud = ["serde", "serde_json", "quick-xml", "hyper", "reqwest", "reqwest/json","reqwest/stream", "chrono/serde", "base64", "rand", "ring"]
azure = ["cloud"]
gcp = ["cloud", "rustls-pemfile"]
aws = ["cloud"]
Expand Down
12 changes: 11 additions & 1 deletion object_store/src/client/retry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use reqwest::header::LOCATION;
use reqwest::{Response, StatusCode};
use std::time::{Duration, Instant};
use tracing::info;
use snafu::Error as SnafuError;

/// Retry request error
#[derive(Debug)]
Expand Down Expand Up @@ -192,9 +193,18 @@ impl RetryExt for reqwest::RequestBuilder {
},
Err(e) =>
{
let mut do_retry = false;
if let Some(source) = e.source() {
if let Some(e) = source.downcast_ref::<hyper::Error>() {
if e.is_connect() || e.is_closed() || e.is_incomplete_message() {
do_retry = true;
}
}
}

if retries == max_retries
|| now.elapsed() > retry_timeout
|| !e.is_request() {
|| !do_retry {

return Err(Error{
retries,
Expand Down

0 comments on commit b68d675

Please sign in to comment.