OutOfMemoryError on S3 put of large file when max heap is limited #5850
Labels
bug
This issue is a bug.
p1
This is a high priority issue
potential-regression
Marking this issue as a potential regression to be checked by team member
Describe the bug
Starting with v2.30.9, when I attempt to s3 put a large file, and my maximum heap is limited, I suffer an OutOfMemoryException. I have not witnessed this with previous versions.
Regression Issue
Expected Behavior
Large file puts successfully when max heap is relatively small.
Current Behavior
When heap is small, put of large file will result in OutOfMemoryException.
When file is large (2gb) will always result in OutOfMemoryException.
See reproduction below.
Reproduction Steps
I'm a clojure developer so forgive my rusty Java skills.
And apologies if I'm doing something goofy and this "just happened to work" in previous versions.
Summary
For versions 2.30.9 to 2.30.11 (latest as of this writing)
OutOfMemoryError: Java heap space
OutOfMemoryError: Requested array size exceeds VM limit
For versions < 2.30.9
Test Source Code
Given
src/main/java/S3Test.java
:And
./pom.xml
:Environment Setup
I went with a local minio server as my S3 target launched like so:
Java version is:
Sanity Test
(I'll leave out the copious mvn INFO output)
Let's put a 1mb file with a max heap of 4gb using v2.30.11
Ok now let's fetch that same file
All looks fine
Reproduction
[fail] v2.30.11 put 2g file 200mb heap
Ok, now let's try to put a 2g file with a max heap of 200mb using v2.30.11
[pass] v2.30.8 put 2g file 200mb heap
Let's try the same again but with v2.30.8
It works.
[pass] v2.30.8 get 2gb file 200mb heap
And with the same limited heap, lets get the file with v2.30.8
works fine.
[pass] v2.30.11 get 2gb file 200mb heap
We don't seem to have issues with get on sdk v2.30.11
all is good.
[fail] v2.30.10 put 2gb file 200mb heap
[fail] v2.30.9 put 2gb file 200mb heap
[fail] v2.30.11 put 2gb file 2gb heap
Maybe 200mb is silly small, let's try a 2gb heap.
[fail] v2.30.11 put 2gb file 8gb heap
Let's give ourselves some elbow room.
Huh! Notice this time though:
Requested array size exceeds VM limit
, a different issue maybe.[pass] v2.30.11 put 1gb file 8gb heap
Let's try a smaller file then:
Ok that worked.
[fail] v2.30.11 put 1gb file 1gb heap
But if we reduce the heap to 1gb, we fail.
Possible Solution
In the 2.30.9 changelog I see:
Feels like the new behaviour I am witnessing might be related to this change.
Additional Information/Context
I've been using the aws sdk for a long while without any issues.
Thanks for all the hard work!
AWS Java SDK version used
2.30.8,2.30.9,2.30.10,2.30.11
JDK version used
openjdk 23.0.1 2024-10-15
Operating System and version
Linux pop-os 6.9.3-76060903-generic #202405300957
173698068022.04~44ea8a9 SMP PREEMPT_DYNAMIC Thu J x86_64 x86_64 x86_64 GNU/LinuxThe text was updated successfully, but these errors were encountered: