Skip to content

Fixed the issue in S3 multipart client where the list of parts could … #4998

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

Merged
merged 2 commits into from
Mar 7, 2024

Conversation

zoewangg
Copy link
Contributor

@zoewangg zoewangg commented Mar 7, 2024

Motivation and Context

Fixed the issue in S3 multipart client where the list of parts could be out of order in CompleteMultipartRequest, causing The list of parts was not in ascending order error to be thrown.

This was a regression introduced in #4908. The root cause is that the type of completedParts was changed from AtomicReferenceArray to ConcurrentHashMap, which is not sorted when the SDK sends the request.

Modifications

  • Change back to AtomicReferenceArray since it should provide better performance than ConcurrentHashMap
  • Ensure completeMultipart is only invoked once.

Testing

Added unit tests

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

@zoewangg zoewangg requested a review from a team as a code owner March 7, 2024 01:47
@@ -94,7 +94,7 @@ public String uploadId() {
}

public Map<Integer, CompletedPart> existingParts() {
return existingParts != null ? Collections.unmodifiableMap(existingParts) : null;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this since this seems a bit overkill for an internal API.

@@ -193,15 +199,16 @@ public void onComplete() {
}

private void completeMultipartUploadIfFinished(int requestsInFlight) {
if (isDone && requestsInFlight == 0) {
if (isDone && requestsInFlight == 0 && completedMultipartInitiated.compareAndSet(false, true)) {
Copy link
Contributor Author

@zoewangg zoewangg Mar 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added back this check. It was removed as part of the refactoring for some reason.

Comment on lines -203 to -204
} else {
parts = existingParts.values().toArray(new CompletedPart[0]);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This else block is not needed since mergeCompletedParts should handle it

…be out of order in the CompleteMultipartRequest, causing "The list of parts was not in ascending order" error to be thrown.
@zoewangg zoewangg force-pushed the zoewang/fixMultipartUpload branch from 6b63903 to 60fa08d Compare March 7, 2024 03:13
Copy link

sonarqubecloud bot commented Mar 7, 2024

@zoewangg zoewangg enabled auto-merge (squash) March 7, 2024 17:36
@zoewangg zoewangg disabled auto-merge March 7, 2024 17:36
@zoewangg zoewangg enabled auto-merge (squash) March 7, 2024 17:36
@zoewangg zoewangg merged commit 238c9a7 into master Mar 7, 2024
@zoewangg zoewangg deleted the zoewang/fixMultipartUpload branch March 7, 2024 18:10
akidambisrinivasan pushed a commit to akidambisrinivasan/aws-sdk-java-v2 that referenced this pull request Jun 28, 2024
…be out of order in the CompleteMultipartRequest, causing "The list of parts was not in ascending order" error to be thrown. (aws#4998)
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