Skip to content
This repository was archived by the owner on Jul 31, 2025. It is now read-only.

Conversation

@michaelf-stratoscale
Copy link
Contributor

@michaelf-stratoscale michaelf-stratoscale commented Apr 11, 2019

…multiparts

@michaelf-stratoscale
Copy link
Contributor Author

reference to an issue will be added shortly

@michaelf-stratoscale
Copy link
Contributor Author

#2557

@jasdel jasdel added the needs-review This issue or pull request needs review from a core team member. label May 7, 2019
@jasdel jasdel changed the title S3 manager upload check for empty part before checking the number of … service/s3/s3manager: Fix uploader to check for empty part before max parts check May 15, 2019
@jasdel
Copy link
Contributor

jasdel commented May 15, 2019

Thanks for taking the time to create this PR @michaelf-stratoscale. The logic makes sense and looks to fix the issue with the max parts corresponds with the reader's EOF exactly. I agree this is a bug that needs to be fixed. I think there are two potentially negative behavior that could result:

  • If the input reader's is larger than MaxUploadParts*PartSize the uploader will read an additional up to PartSize before deciding to throw the read part chunk away since number of parts has reached MaxUploadParts.

  • If the input reader is an unbounded stream (i.e. no length and not seekable) the uploader would block reading the input reader until EOF or PartSize bytes were available. Since the uploader doesn't have a ContentLength parameter the only ways to control how many bites are uploaded is with a bounded reader, or manipulating MaxUploadParts.

Both of these situations require the user to be using MaxUploadParts to control the total size of content uploaded, which is a fragile method since objects would need to be PartSize*N size. Using an io.LimitReader would provide a much safer method of accomplishing this goal.

Clarified S3 Upload Manager's MaxUploadPart parameter that it must not be used to limit the total number of bytes uploaded. An io.LimitReader should be used instead.
Copy link
Contributor

@jasdel jasdel left a comment

Choose a reason for hiding this comment

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

Made a minor update clarifying the role of MaxUploadParts, and how it must not be used as a tool to limit the total size of the object uploaded.

@michaelf-stratoscale
Copy link
Contributor Author

Hey @jasdel in the example that i wrote in the issue #2557 i set MaxUploadParts in my production code i don't really set it, i just use the default, my only edge case is when the data that i get is in exactly 10K parts and because i use io.MultiReader i get 10K+1 parts.

In any case the code looks good. Do you know when it's going to be pushed?

@jasdel
Copy link
Contributor

jasdel commented May 17, 2019

Hi @michaelf-stratoscale i pushed a small change to this PR that adds unit tests. I'll merge the change in once the Travis tests pass.

@jasdel jasdel merged commit 27db922 into aws:master May 20, 2019
@aws-sdk-go-automation aws-sdk-go-automation mentioned this pull request May 20, 2019
diehlaws pushed a commit to diehlaws/aws-sdk-go that referenced this pull request Jul 2, 2019
… parts check (aws#2556)

Fixes the S3 Upload manager's behavior for uploading exactly MaxUploadParts * PartSize to S3. The uploader would previously return an error after the full content was uploaded, because the assert on max upload parts was occurring before the check if there were any more parts to upload.

This change fixes that logic so that the uploader first checks if there are any more chunks to upload before checking if the max number of parts to upload have been reached.

Also clarifies the uploader's behavior of MaxUploadParts, and that it must not be used to limit the uploader's total upload size. an io.LimitReader can be used for that purpose.

Fix aws#2557
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

needs-review This issue or pull request needs review from a core team member.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants