You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sedona.apache.org by pr...@apache.org on 2026/06/02 19:46:24 UTC

(sedona-spatialbench) 02/06: feat(raster): retry transient S3 errors with exponential backoff

This is an automated email from the ASF dual-hosted git repository.

prantogg pushed a commit to branch pranav/feature/raster-benchmark
in repository https://gitbox.apache.org/repos/asf/sedona-spatialbench.git

commit fe87f4ff222bc7ddee1a2751b6c33c362772d6d3
Author: Pranav Toggi <pr...@gmail.com>
AuthorDate: Mon Jun 1 22:27:09 2026 -0700

    feat(raster): retry transient S3 errors with exponential backoff
    
    Attach an object_store RetryConfig to the S3 client so 5xx/SlowDown/
    timeout errors are retried with backoff+jitter. Required for long,
    high-concurrency raster uploads where throttling is expected.
    
    Co-Authored-By: Claude Opus 4.8 (1M context) <no...@anthropic.com>
---
 spatialbench-cli/src/s3_writer.rs | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/spatialbench-cli/src/s3_writer.rs b/spatialbench-cli/src/s3_writer.rs
index 3a25dfa..9900040 100644
--- a/spatialbench-cli/src/s3_writer.rs
+++ b/spatialbench-cli/src/s3_writer.rs
@@ -29,9 +29,10 @@ use bytes::Bytes;
 use log::{debug, info};
 use object_store::aws::AmazonS3Builder;
 use object_store::path::Path as ObjectPath;
-use object_store::ObjectStore;
+use object_store::{BackoffConfig, ObjectStore, RetryConfig};
 use std::io::{self, Write};
 use std::sync::Arc;
+use std::time::Duration;
 use tokio::sync::mpsc;
 use tokio::sync::oneshot;
 use url::Url;
@@ -71,8 +72,24 @@ pub fn parse_s3_uri(uri: &str) -> Result<(String, String), io::Error> {
 /// `AWS_DEFAULT_REGION`, `AWS_REGION`, `AWS_SESSION_TOKEN`, `AWS_ENDPOINT`, etc.
 pub fn build_s3_client(bucket: &str) -> Result<Arc<dyn ObjectStore>, io::Error> {
     debug!("Building S3 client for bucket: {}", bucket);
+
+    // Retry transient errors (5xx, SlowDown, timeouts) with exponential backoff
+    // and jitter. Important for long multi-TB raster runs at high upload
+    // concurrency, where S3 throttling is expected. retry_timeout stays under
+    // 5 min per object_store's credential/payload validity guidance.
+    let retry = RetryConfig {
+        backoff: BackoffConfig {
+            init_backoff: Duration::from_millis(200),
+            max_backoff: Duration::from_secs(20),
+            base: 2.0,
+        },
+        max_retries: 10,
+        retry_timeout: Duration::from_secs(180),
+    };
+
     let client = AmazonS3Builder::from_env()
         .with_bucket_name(bucket)
+        .with_retry(retry)
         .build()
         .map_err(|e| io::Error::other(format!("Failed to create S3 client: {}", e)))?;
     info!("S3 client created successfully for bucket: {}", bucket);