Skip to content

Commit 6e897bf

Browse files
chore: retry for S3 and blob store calls (#968)
add retry config for S3 and blob-store configs retry config: - max retries - 5 - retry timeout - 120 secs - backoff config (default by object_store crate) - initial backoff - 100 ms (initial delay before 1st retry) max backoff - 15 secs (max delay between retries) base - 2 (exponential backoff factor i.e. 2s, 4s, 8s etc)
1 parent 9396d9b commit 6e897bf

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

server/src/storage/azure_blob.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use datafusion::datasource::object_store::{
3030
};
3131
use datafusion::execution::runtime_env::RuntimeConfig;
3232
use object_store::azure::{MicrosoftAzure, MicrosoftAzureBuilder};
33-
use object_store::{ClientOptions, ObjectStore, PutPayload};
33+
use object_store::{BackoffConfig, ClientOptions, ObjectStore, PutPayload, RetryConfig};
3434
use relative_path::{RelativePath, RelativePathBuf};
3535
use std::path::Path as StdPath;
3636
use url::Url;
@@ -120,10 +120,17 @@ impl AzureBlobConfig {
120120
.with_connect_timeout(Duration::from_secs(CONNECT_TIMEOUT_SECS))
121121
.with_timeout(Duration::from_secs(REQUEST_TIMEOUT_SECS));
122122

123+
let retry_config = RetryConfig {
124+
max_retries: 5,
125+
retry_timeout: Duration::from_secs(120),
126+
backoff: BackoffConfig::default(),
127+
};
128+
123129
let mut builder = MicrosoftAzureBuilder::new()
124130
.with_endpoint(self.endpoint_url.clone())
125131
.with_account(&self.account)
126-
.with_container_name(&self.container);
132+
.with_container_name(&self.container)
133+
.with_retry(retry_config);
127134

128135
if let Some(access_key) = self.access_key.clone() {
129136
builder = builder.with_access_key(access_key)

server/src/storage/s3.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use futures::{StreamExt, TryStreamExt};
2828
use object_store::aws::{AmazonS3, AmazonS3Builder, AmazonS3ConfigKey, Checksum};
2929
use object_store::limit::LimitStore;
3030
use object_store::path::Path as StorePath;
31-
use object_store::{ClientOptions, ObjectStore, PutPayload};
31+
use object_store::{BackoffConfig, ClientOptions, ObjectStore, PutPayload, RetryConfig};
3232
use relative_path::{RelativePath, RelativePathBuf};
3333

3434
use std::collections::BTreeMap;
@@ -218,13 +218,19 @@ impl S3Config {
218218
if self.skip_tls {
219219
client_options = client_options.with_allow_invalid_certificates(true)
220220
}
221+
let retry_config = RetryConfig {
222+
max_retries: 5,
223+
retry_timeout: Duration::from_secs(30),
224+
backoff: BackoffConfig::default(),
225+
};
221226

222227
let mut builder = AmazonS3Builder::new()
223228
.with_region(&self.region)
224229
.with_endpoint(&self.endpoint_url)
225230
.with_bucket_name(&self.bucket_name)
226231
.with_virtual_hosted_style_request(!self.use_path_style)
227-
.with_allow_http(true);
232+
.with_allow_http(true)
233+
.with_retry(retry_config);
228234

229235
if self.set_checksum {
230236
builder = builder.with_checksum_algorithm(Checksum::SHA256)

0 commit comments

Comments
 (0)