Skip to content

Optimize S3 server-side compose capability check using encoded part sizes - #149

Merged
tomdesair merged 1 commit into
masterfrom
feature/s3-compose-part-size-optimization
Oct 25, 2026
Merged

tomdesair merged 1 commit into
masterfrom
feature/s3-compose-part-size-optimization

Conversation

@tomdesair

Copy link
Copy Markdown
Owner

Summary

This PR optimizes the S3 server-side compose capability check and tail rollback inspection by resolving part sizes directly from the part key name suffix, eliminating N+1 remote statObject HTTP roundtrips.

Changes

  • S3Utils.getPartSize: Extracts the _<size> suffix from part keys in O(1) time without network calls, with automatic fallback to statObject for legacy or un-suffixed keys.
  • S3ServerSideComposeHelper:
    • Adds thread-safe composeSupported toggle guarded by ReentrantReadWriteLock (isComposeSupported(), setComposeSupported(boolean)).
    • Adds canCompose(bucket, partKeys, minPartSize) evaluating S3 compose requirements (all non-final parts >= 5 MiB) using O(1) size lookups.
    • Adds canComposePartialUploads(partialUploads, minPartSize) centralizing multi-part size validation logic.
    • Initializes fallback sync MinioClient in the explicit endpoint constructor via S3Utils.buildMinioClient.
  • S3StorageService:
    • Replaces O(N) statObject calls in finalizeCompletedUploadIfFinished with delegated call to s3ComposeHelper.canCompose(...).
    • Streamlines prepareStreamWithExistingIncompletePart to calculate part sizes in a single pass.
    • Delegates compose capability state management to s3ComposeHelper.
  • S3ConcatenationService:
    • Reuses s3ComposeHelper.canComposePartialUploads(...) in merge.
    • Automatically marks s3ComposeHelper.setComposeSupported(false) on compose failure before falling back to streaming re-upload so subsequent requests immediately bypass failing compose calls.
  • Tests & Quality:
    • Added comprehensive unit tests in S3UtilsTest, S3ServerSideComposeHelperTest, S3StorageServiceTest, and S3ConcatenationServiceTest.
    • Formatted via Google Java Style (fmt-maven-plugin).
    • 100% diff line coverage on modified/added lines.

…izes

- Add S3Utils.getPartSize to resolve part sizes in O(1) time from encoded part key name suffixes with statObject fallback
- Add canCompose and canComposePartialUploads to S3ServerSideComposeHelper to eliminate N+1 statObject HTTP calls
- Manage compose capability flag in S3ServerSideComposeHelper with automatic fallback disablement in S3ConcatenationService
- Streamline prepareStreamWithExistingIncompletePart in S3StorageService to inspect parts in a single pass
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage is 95.049% — feature/s3-compose-part-size-optimization into master. No base build found for master.

@tomdesair
tomdesair merged commit 0dbcaaf into master Oct 25, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants