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 calculate optimal part size bug #608
Conversation
Hi,
The file that I used was about 22 MB, which is bigger than 5MB as you have mentioned. |
HI,
I am using minio-py for my flask app, Although I used python 2.7, the |
Yes but you are missing that we do int() casting Here are the results for python2.7 and python3.6
So i am not sure what this PR is really doing, the title doesn't indicate what it is doing. The PR only adds tests but not any bug in the actual code. Can you restate what is the real issue here? |
if the first |
Can you provide a test case? |
Ah I see now it won't happen in the code as is while using put_object because we never send optimal_part_info a value which is < MIN_PART_SIZE
The problem is when we use optimal_part_info() elsewhere it is possible that someone might pass in size < MIN_PART_SIZE I would suggest a better fix to be following code with diff --git a/minio/helpers.py b/minio/helpers.py
index 304b0e7..015dd65 100644
--- a/minio/helpers.py
+++ b/minio/helpers.py
@@ -584,6 +584,8 @@ def optimal_part_info(length):
if length > MAX_MULTIPART_OBJECT_SIZE:
raise InvalidArgumentError('Input content size is bigger '
' than allowed maximum of 5TiB.')
+ if length <= MIN_PART_SIZE:
+ return 1, length, length |
I don't think it is better solution. For my environment, the error as below:
if length less than MAX_MULTIPART_COUNT * MIN_PART_SIZE, part_size_float could be zero. so |
FWIW - I don't see this error on python3.6.3
Choosing
I am not sure how it is possible on your system though. |
HI, I found the root cause, for our flask app, we use the
the source code as below:
so for python2.7, the function
the first So if use python2.7 and |
This is one of the reasons always unhappy with Also would be nice to add test cases for other situations as well where we expect the result to be float. |
8c0064f
to
04a1901
Compare
for some situations(for example, use future package), math.ceil will return an integer for python2.x, it will cause errors for calculate optimal part size for multipart uploads. So, add __future__ module to make sure the integer division return a float.
04a1901
to
8d5febd
Compare
@harshavardhana Thanks for your support, add test cases for this maybe is not needed, because this is a special case, just make sure the result of integers devision is a float, import |
Uploaded failed when length larger than 5MB put_object.
env:
python version: 2.7.5
minio version: 2.2.6