AWS S3: Uploading large file fails with ResetException: Failed to reset the request input stream

Question:

Can anyone tell me what is wrong with the following code such that a large file upload (>10GB) always fails with ResetException: Failed to reset the request input stream?

The failure always happens after a while (i.e. after around 15 minutes), which must mean that the upload process is executing only to fail somewhere in the middle.

Here’s what I’ve tried to debug the problem:

  1. in.marksSupported() == false // checking if mark is supported on my FileInputStream

    I highly suspect that this is the problem, since the S3 SDK seems to want to do a reset operation at some point during the upload, probably if the connection is lost or if the transfer process encounters some error.

  2. Wrapping my FileInputStream within a BufferedInputStream to enable marking. Now calling in.marksSupported() returns true, meaning that mark support is there. Strangely, the upload process still fails with the same kind of error.
  3. Adding putRequest.getRequestClientOptions.setReadLimit(n), where n=100000 (100kb), and 800000000 (800mb) but it still throws the same error. I suspect because this parameter is used to reset the stream, which, as stated above, isn’t supported on a FileInputStream

Interestingly, the same problem doesn’t happen on my AWS development account. I assume that is just because the dev account is not under a heavy load as my production account, meaning that the upload process can execute as smoothly as possible without any failure at all.

Please have a look at my code below:

Here is the complete stack trace:

Answer:

This definitely looks like a bug, which I have reported. The solution is to use the other constructor which accepts a File instead of InputStream

Leave a Reply