Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(services/s3): Fix s3 batch max operations #2418

Merged
merged 1 commit into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions core/src/services/s3/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static ENDPOINT_TEMPLATES: Lazy<HashMap<&'static str, &'static str>> = Lazy::new
});

const DEFAULT_WRITE_MIN_SIZE: usize = 8 * 1024 * 1024;

const DEFAULT_BATCH_MAX_OPERATIONS: usize = 1000;
/// Aws S3 and compatible services (including minio, digitalocean space, Tencent Cloud Object Storage(COS) and so on) support.
/// For more information about s3-compatible services, refer to [Compatible Services](#compatible-services).
///
Expand Down Expand Up @@ -93,6 +93,8 @@ pub struct S3Builder {
/// the part size of s3 multipart upload, which should be 5 MiB to 5 GiB.
/// There is no minimum size limit on the last part of your multipart upload
write_min_size: Option<usize>,
/// batch_max_operations
batch_max_operations: Option<usize>,
}

impl Debug for S3Builder {
Expand Down Expand Up @@ -508,6 +510,12 @@ impl S3Builder {
pub fn write_min_size(&mut self, write_min_size: usize) -> &mut Self {
self.write_min_size = Some(write_min_size);

self
}
/// Set maximum batch operations of this backend.
pub fn batch_max_operations(&mut self, batch_max_operations: usize) -> &mut Self {
self.batch_max_operations = Some(batch_max_operations);

self
}
}
Expand Down Expand Up @@ -696,7 +704,9 @@ impl Builder for S3Builder {
)
.with_context("service", Scheme::S3));
}

let batch_max_operations = self
.batch_max_operations
.unwrap_or(DEFAULT_BATCH_MAX_OPERATIONS);
debug!("backend build finished");
Ok(S3Backend {
core: Arc::new(S3Core {
Expand All @@ -714,6 +724,7 @@ impl Builder for S3Builder {
loader,
client,
write_min_size,
batch_max_operations,
}),
})
}
Expand Down Expand Up @@ -773,7 +784,7 @@ impl Accessor for S3Backend {
presign_write: true,

batch: true,
batch_max_operations: Some(1000),
batch_max_operations: Some(self.core.batch_max_operations),

..Default::default()
});
Expand Down
1 change: 1 addition & 0 deletions core/src/services/s3/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ pub struct S3Core {
pub loader: AwsLoader,
pub client: HttpClient,
pub write_min_size: usize,
pub batch_max_operations: usize,
}

impl Debug for S3Core {
Expand Down