Skip to content

Fix CompletableFuture hangs when RetryStrategy/MetricsCollector raise errors #6125

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

Conversation

alextwoods
Copy link
Contributor

Fix #6008 - Improve error handling in futures in the async pipeline.

Motivation and Context

Errors raised by the RetryStrategy or MetricsCollector in the async request pipeline previously caused the returned future to hang indefinitely because they were never setting a completion state on the returned future. See #6008.

Modifications

  • Improve error handling in futures in the async pipeline

Testing

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

@alextwoods alextwoods requested a review from a team as a code owner May 21, 2025 20:23
Copy link

@@ -57,6 +57,9 @@ public CompletableFuture<OutputT> execute(SdkHttpFullRequest input, RequestExecu
} else {
future.complete(r);
}
}).exceptionally(t -> {
Copy link
Contributor

Choose a reason for hiding this comment

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

whenComplete already handles t != null exception , why do we need exceptionally here?

Copy link
Contributor Author

@alextwoods alextwoods May 22, 2025

Choose a reason for hiding this comment

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

This is to handle an exception raised in the whenComplete (ie by the metrics collector)- this is called on the new future returned from whenComplete and not on the original future.

@alextwoods alextwoods added this pull request to the merge queue May 23, 2025
Merged via the queue into master with commit 321a0b0 May 23, 2025
26 checks passed
@alextwoods alextwoods deleted the feature/master/alexwoo/handle-retrypolicy-exception branch May 23, 2025 16:31
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.

DynamoDB CompletableFutures may hang forever if there is an exception in retry policy checks (DynamoDbAsyncClient + RetryCondition)
2 participants