Skip to content

S3AsyncClient#getObject could complete successfully with no file written to disk #5732

@aymkhalil

Description

@aymkhalil

Describe the bug

A call to client.getObject(request, destinationPath) could complete successfully with no file written to disk. We've seen this in production and was able to write a minimal repro by starting a download, and then manually deleting the file while its being downloaded (for reproduction purposes only, but think a race condition in the business logic) and we could see the future completes successfully.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

If no file was written to disk, I'd expect the download future to complete exceptionally - either when the external event that deleted the file occurred, or at least when the download operation completes - at this point it should be able to verify if a file was written to disk or not.

Current Behavior

The future will complete successfully although no file is written to disk. An application would typically assume if the future completed without exceptions, then the download was successful and a file was written to disk.

Reproduction Steps

Here is a self contained repo that basically
1\ uploads a 1 GB to
2\ downloads the uploaded file to /tmp/download/1gb.bin
3\ 5 seconds after the download starts (at this point, the file is being written to disk) delete the file
4\ few seconds later, the future would complete without and exception

async-s3-get-object.zip

To run:

unzip async-s3-get-object.zip
cd async-s3-get-object.zip
mvn package
java -jar target/async-s3-get-object-1.0-SNAPSHOT.jar <ACCESS_KEY> <SECRET_KEY> <ENDPOINT> <REGION> <BUCKET> 

(for example: java -jar target/async-s3-get-object-1.0-SNAPSHOT.jar XXX XXX "https://s3.amazonaws.com" "us-west-1" "my-test-bucket"

You should see the follow log

File with 1GB contentLength upload successfully: aym-000-test/1gb.bin
Starting first download attempt: aym-000-test/1gb.bin to /tmp/download/1gb.bin
enforcing a delete after 5 seconds from starting the download
Future completed with no errors, but file not found at: /tmp/download/1gb.bin

Possible Solution

No response

Additional Information/Context

No response

AWS Java SDK version used

2.29.21

JDK version used

java version "17.0.3.1" 2022-04-22 LTS

Operating System and version

macOS 14.0

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.p2This is a standard priority issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions