alexmojaki / s3-stream-upload

Manages streaming of data to AWS S3 without knowing the size beforehand and without keeping it all in memory or writing to disk.
MIT License
208 stars 62 forks source link

com.amazonaws.http.timers.client.SdkInterruptedException thrown #25

Closed cwhorton closed 4 years ago

cwhorton commented 4 years ago

Thank you for creating, documenting and sharing this code. My use case is to compress files while in transit to S3 so they arrive as a single .zip archive as I normally cannot make a zip on disk first and then upload (I'm dealing with files ranging between 5 MBs to around 500 GBs).

I've written a JUnit test and it works beautifully. But, when I run the exact same code with the exact same parameters on the exact same file to zip and upload from my tomcat web app I always fail with com.amazonaws.AbortedException Caused by: com.amazonaws.http.timers.client.SdkInterruptedException.

The relevant portion of the log says:

2020-02-21 11:41:25,989 alex.mojaki.s3upload.StreamTransferManager [INFO] Initiated multipart upload to us-west-2-fmnode-backups/a814/Databases/Assets.fmp12.2020-02-21-11-41.zip with full ID qQX43rqfmSU4_k8Oz4YVCYEHAaRSvRWf0OAWJNwR9KHNntT5Zw1nUpsgsLqTJv6H162z2piZeSpd3hKlA2iHzGYf.TVqdKS8ZlHN_fcriExm15g5cqbOUUJihBrUR.l.
2020-02-21 11:41:26,208 alex.mojaki.s3upload.MultiPartOutputStream [INFO] Called close() on [MultipartOutputStream for parts 1 - 10000]
2020-02-21 11:41:26,223 alex.mojaki.s3upload.MultiPartOutputStream [INFO] Called close() on [MultipartOutputStream for parts 1 - 10000]
2020-02-21 11:41:26,223 alex.mojaki.s3upload.MultiPartOutputStream [WARN] [MultipartOutputStream for parts 1 - 10000] is already closed
2020-02-21 11:41:26,223 com.austinmichael.hosting.filemaker.nodeagent.rest.AbstractResource [ERROR] java.util.concurrent.ExecutionException: com.amazonaws.AbortedException: 
java.lang.RuntimeException: java.util.concurrent.ExecutionException: com.amazonaws.AbortedException: 
    at alex.mojaki.s3upload.ExecutorServiceResultsHandler$1.next(ExecutorServiceResultsHandler.java:72)
Caused by: java.util.concurrent.ExecutionException: com.amazonaws.AbortedException: 
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
        .....
Caused by: com.amazonaws.AbortedException: 
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleInterruptedException(AmazonHttpClient.java:807)
        ....
Caused by: com.amazonaws.http.timers.client.SdkInterruptedException
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.checkInterrupted(AmazonHttpClient.java:854)

My code is

StreamTransferManager manager = new StreamTransferManager(this.bucketName, this.pathRoot + path, s3)
                .numStreams(1)
                .numUploadThreads(1)
                .queueCapacity(2)
                .partSize(5);

                final List<MultiPartOutputStream> streams = manager.getMultiPartOutputStreams();

            //Just one stream
        MultiPartOutputStream outputStream = streams.get(0);
        try {
            ZipUtil.compress(file, outputStream);
            outputStream.close();
        } catch (Exception e)
        {
            log.error(e.getMessage(),e);
            manager.abort(e);
        }
        manager.complete();  // Exception thrown here

It works 100% of the time with my JUnit test and fails 100% of the time in Tomcat WAR. Please let me know if you see something I should adjust or even what my next step should be.

Thanks. Carl

alexmojaki commented 4 years ago

Sorry, I don't have any ideas :(

cwhorton commented 4 years ago

It was my fault, mismatched AWS API dependency versions. It works now. Thanks!