Skip to content

Commit 7ae1227

Browse files
committed
Add object store retry config for azure
1 parent 8643409 commit 7ae1227

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

rust/lance-io/src/object_store.rs

+26-11
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use lance_core::utils::tokio::get_num_compute_intensive_cpus;
2222
use object_store::aws::{
2323
AmazonS3ConfigKey, AwsCredential as ObjectStoreAwsCredential, AwsCredentialProvider,
2424
};
25+
use object_store::azure::MicrosoftAzureBuilder;
2526
use object_store::gcp::{GcpCredential, GoogleCloudStorageBuilder};
2627
use object_store::{
2728
aws::AmazonS3Builder, azure::AzureConfigKey, gcp::GoogleConfigKey, local::LocalFileSystem,
@@ -729,6 +730,12 @@ impl StorageOptions {
729730
if let Ok(value) = std::env::var("AWS_ALLOW_HTTP") {
730731
options.insert("allow_http".into(), value);
731732
}
733+
if let Ok(value) = std::env::var("OBJECT_STORE_CLIENT_MAX_RETRIES") {
734+
options.insert("client_max_retries".into(), value);
735+
}
736+
if let Ok(value) = std::env::var("OBJECT_STORE_CLIENT_RETRY_TIMEOUT") {
737+
options.insert("client_retry_timeout".into(), value);
738+
}
732739
Self(options)
733740
}
734741

@@ -790,7 +797,7 @@ impl StorageOptions {
790797
.unwrap_or(3)
791798
}
792799

793-
/// Max retry times to set in RetryConfig for s3 client
800+
/// Max retry times to set in RetryConfig for object store client
794801
pub fn client_max_retries(&self) -> usize {
795802
self.0
796803
.iter()
@@ -799,7 +806,7 @@ impl StorageOptions {
799806
.unwrap_or(10)
800807
}
801808

802-
/// Seconds of timeout to set in RetryConfig for s3 client
809+
/// Seconds of timeout to set in RetryConfig for object store client
803810
pub fn client_retry_timeout(&self) -> u64 {
804811
self.0
805812
.iter()
@@ -865,6 +872,13 @@ async fn configure_store(
865872
// block size where we don't see a latency penalty.
866873
let file_block_size = options.block_size.unwrap_or(4 * 1024);
867874
let cloud_block_size = options.block_size.unwrap_or(64 * 1024);
875+
let max_retries = storage_options.client_max_retries();
876+
let retry_timeout = storage_options.client_retry_timeout();
877+
let retry_config = RetryConfig {
878+
backoff: Default::default(),
879+
max_retries,
880+
retry_timeout: Duration::from_secs(retry_timeout),
881+
};
868882
match url.scheme() {
869883
"s3" | "s3+ddb" => {
870884
storage_options.with_env_s3();
@@ -877,13 +891,6 @@ async fn configure_store(
877891
// });
878892
// }
879893

880-
let max_retries = storage_options.client_max_retries();
881-
let retry_timeout = storage_options.client_retry_timeout();
882-
let retry_config = RetryConfig {
883-
backoff: Default::default(),
884-
max_retries,
885-
retry_timeout: Duration::from_secs(retry_timeout),
886-
};
887894
let mut storage_options = storage_options.as_s3_options();
888895
let region = resolve_s3_region(&url, &storage_options).await?;
889896
let (aws_creds, region) = build_aws_credential(
@@ -938,7 +945,9 @@ async fn configure_store(
938945
}
939946
"gs" => {
940947
storage_options.with_env_gcs();
941-
let mut builder = GoogleCloudStorageBuilder::new().with_url(url.as_ref());
948+
let mut builder = GoogleCloudStorageBuilder::new()
949+
.with_url(url.as_ref())
950+
.with_retry(retry_config);
942951
for (key, value) in storage_options.as_gcs_options() {
943952
builder = builder.with_config(key, value);
944953
}
@@ -965,7 +974,13 @@ async fn configure_store(
965974
}
966975
"az" => {
967976
storage_options.with_env_azure();
968-
let (store, _) = parse_url_opts(&url, storage_options.as_azure_options())?;
977+
let mut builder = MicrosoftAzureBuilder::new()
978+
.with_url(url.as_ref())
979+
.with_retry(retry_config);
980+
for (key, value) in storage_options.as_azure_options() {
981+
builder = builder.with_config(key, value);
982+
}
983+
let store = builder.build()?;
969984
let store = Arc::new(store).traced();
970985

971986
Ok(ObjectStore {

0 commit comments

Comments
 (0)