Open maoueh opened 11 months ago
I have the same issue with my substreams tier2 instances. They would consume all available tcp_mem until the system crashed.
I've been poking around trying to figure this out for a while, and I think I've found the issue, the reader.Body is not closed here: https://github.com/streamingfast/dstore/blob/3924b3b36c778c14ef73ce108d965c774fb27fff/s3store.go#L335
I added a reader.Body.Close()
and that seems to have fixed the issue, tcp_mem is down to nothing.
or am I wrong because it is closed later?
It's closed later indeed, that the point of the OpenObject
. But your investigation pointa to something in that vein, there is definitely something not closed properly while the streaming is happening.
We had a "sample" binary that was doing in loop OpenObject
then tried to read the merged block, I'll try to find it back and set up the infra to reproduce the error more easily.
It appears our streaming code for S3 (or maybe in the S3 library itself) has a bug that leads to weird file issue where the content is not read fully.
The bug seems to happen non-systematically, which makes me think it could be a wrong "error" handling when the stream closes unexpectedly.
This problem has been reported a few times over the past 1-2 years, against Ceph, S3 directly and SeaweedFS. The current workaround is to set
DSTORE_S3_BUFFERED_READ=true
which reads everything in one show in memory and then act as aio.Reader
. This however creates memory pressure as the full file is held in memory before being streamed.See https://github.com/streamingfast/firehose-core/issues/15 for some details, and some logs from SeaweedFS. We can see there that SeaweedFS sees internal failure but those leads later to Firehose trying to read corrupted blocks:
Which means someone the "consumer" saw a end of the stream but the actual reading code failed due to some missing bytes.