Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing Java S3 Client Transfer Manager issue with transferComplete() not called for AsyncRequestBody.fromFile #4440

Merged
merged 2 commits into from
Sep 19, 2023

Conversation

joviegas
Copy link
Contributor

Fixing Java S3 Client Transfer Manager issue with transferComplete() not called for AsyncRequestBody.fromFile

Motivation and Context

Root Cause

  • NettyRequestExecutor prematurely cancels the subscription when the last chunk is sent.
  • The logic of shouldContinuePublishing after DoneCheck-OnNext checks < instead of <= in shouldContinuePublishing().

Modifications

  • The actual fix would be to move shouldContinuePublishing before the isDone check and then update < to <= in shouldContinuePublishing().
  • However, we had an internal discussion, and the outcome was not to modify this but to update the TransferManager Code to ensure that we send the transferComplete once all the bytes are received.
  • Added a done flag to ensure that transferComplete is not called more than once.

Testing

  • Added JUnit tests.
  • Included integration tests for the Java client since this issue is primarily observed in the Java S3 client Transfer Manager.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

License

  • I confirm that this pull request can be released under the Apache 2 license

@joviegas joviegas requested a review from a team as a code owner September 15, 2023 20:25
Copy link
Contributor

@cenedhryn cenedhryn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a comment to the NettyRequestExecutor.java shouldContinuePublishing() to indicate that the check can cause issues and what the mitigation is?

@joviegas
Copy link
Contributor Author

joviegas commented Sep 19, 2023

Can we add a comment to the NettyRequestExecutor.java shouldContinuePublishing() to indicate that the check can cause issues and what the mitigation is?

I doubt a comment would help much. We should conduct a Failure Mode Analysis to see what happens if we make the suggested fixe by invoking shouldContinuePublishing before done and modifying written < cl to written <= cl . Just adding a comment might make it seem like we've fully evaluated NettyRequestExecutor's behavior with no room for improvement

Copy link
Contributor

@cenedhryn cenedhryn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A deep dive would be ideal, but likely not happening at this point in time. My concern is that after some time the discussion in the PR will be forgotten and we'll lose context and time figuring out the same thing again, for a different issue and that a comment would let us connect the two parts of the code.
Personally I don't care how people would interpret a comment (if they even saw it). As developers we make trade-off decisions every day, and it's not a bad thing to be prudent. That being said, will leave it up to you.

@sonarcloud
Copy link

sonarcloud bot commented Sep 19, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

82.4% 82.4% Coverage
0.0% 0.0% Duplication

@joviegas joviegas merged commit e565b36 into master Sep 19, 2023
7 checks passed
@joviegas joviegas deleted the joviegas/update_transfer_completed branch May 15, 2024 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants