We are running cljdoc on the cheap. As such, it is memory-constrained.
I've just added s3 backup/restore functionality for our SQLite db using aws-api and noticed an OutOfMemory error when using :GetObject and :PutObject.
Reproduction
To make this easy for anyone to run, I'll reproduce with MinIO Object Store via docker.
(we are using Exoscale, but that is not relevant).
To launch a local MinIO server:
docker run -p 9000:9000 -p 9001:9001 --name minio \
-e "MINIO_ROOT_USER=foouser" \
-e "MINIO_ROOT_PASSWORD=foosecret" \
minio/minio server /data --console-address ":9001"
I wiped up a little script to demonstrate the issue (to be used with deps.edn above).
objheap.clj
The http client seems to be loading the entire object into memory for GetObject and PutObject.
When the object is big, and memory is limited, this can cause OutOfMemory errors.
Thank you for Cognitect's aws-api! I'm just dipping my toe in, so my apologies if I'm making a newbie mistake or if this issue is already well-known.
Dependencies
deps.edn
Description
We are running cljdoc on the cheap. As such, it is memory-constrained. I've just added s3 backup/restore functionality for our SQLite db using aws-api and noticed an OutOfMemory error when using
:GetObject
and:PutObject
.Reproduction
To make this easy for anyone to run, I'll reproduce with MinIO Object Store via docker. (we are using Exoscale, but that is not relevant).
To launch a local MinIO server:
I wiped up a little script to demonstrate the issue (to be used with
deps.edn
above).objheap.clj
Sanity runs
(Your max heap will differ)
Let's put a 1mb file:
And fetch it:
Ok now let's try to put a 1gb file:
And fetch it:
All sane, all good.
Failing runs
Let's start by putting that 1gb file unconstrained (just in case you didn't execute the sanity runs):
And now let's try fetching the 1gb object constrained to 800mb:
The 2nd error is caused by the first (
OutOfMemory
) error.And now let's try putting a 1gb object constrained to 800mb:
Observation
The http client seems to be loading the entire object into memory for
GetObject
andPutObject
. When the object is big, and memory is limited, this can causeOutOfMemory
errors.Is there some way I can work around this?