Skip to content

Fixed the issue where the SDK did not offload future completion #3034

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

Merged
merged 3 commits into from
Feb 21, 2022

Conversation

zoewangg
Copy link
Contributor

@zoewangg zoewangg commented Feb 16, 2022

Motivation and Context

Fixed the issue where the SDK did not offload future completion to the future completion executor

RCA

Happy case workflow (Always complete on futureCompletionExecutor)

  • responseFuture gets completed by futureCompletionExecutor after the future in the AsyncResponseHandler#prepare gets completed

responseHandlerFuture.whenCompleteAsync((r, t) -> {
if (t == null) {
responseFuture.complete(r);
} else {
responseFuture.completeExceptionally(t);
}
}, futureCompletionExecutor);

  • toReturn future gets completed after responseFuture gets completed. This will happen in the futureCompletionExecutor.

executeFuture.whenComplete((r, t) -> {
if (t != null) {
toReturn.completeExceptionally(t);
} else {
toReturn.complete(r);
}

Error case workflow (Most of the time complete on futureCompletionExecutor)

  • responseFuture gets completed exceptionally before responseHandlerFuture gets completed.

public void onError(Throwable error) {
responseFuture.completeExceptionally(error);
wrappedHandler.onError(error);

  • toReturn future gets completed after responseFuture gets completed. This will happen in the event loop thread due to the use of whenComplete.

executeFuture.whenComplete((r, t) -> {
if (t != null) {
toReturn.completeExceptionally(t);
} else {
toReturn.complete(r);
}

Modifications

  • Removed WrappedErrorForwardingResponseHandler. I'm not sure why it's needed since we are relying on responseHandlerFuture to complete the responseFuture anyway.
    - Updated to offload the metrics reporting to futureCompletionExecutor

Testing

Added unit tests

Screenshots (if appropriate)

Types of changes

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

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

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

@zoewangg zoewangg requested a review from a team as a code owner February 16, 2022 00:49
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.

Curious, did the tests fail consistently before adding the fix?

@zoewangg
Copy link
Contributor Author

Curious, did the tests fail consistently before adding the fix?

No, I think the test started to fail because I made the change to offload metrics reporting to the thread completion executor. I'll either revert the change or fix the test

@zoewangg zoewangg force-pushed the zoewang/fixCompletionOffloading branch from 097c0bb to c2c4b47 Compare February 16, 2022 23:31
@zoewangg zoewangg force-pushed the zoewang/fixCompletionOffloading branch from c2c4b47 to c4a1239 Compare February 18, 2022 22:23
@sonarqubecloud
Copy link

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 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@zoewangg zoewangg merged commit 03677b2 into master Feb 21, 2022
@zoewangg zoewangg deleted the zoewang/fixCompletionOffloading branch February 21, 2022 17:24
aws-sdk-java-automation pushed a commit that referenced this pull request May 14, 2024
…4c8714a60

Pull request: release <- staging/c400a56f-efed-42f8-9632-fd54c8714a60
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.

3 participants