Skip to content

Fix overflow bugs in backoff strategy. #1673

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
Mar 2, 2020

Conversation

Quanzzzz
Copy link
Contributor

Fixed issue #1453 based on the proposed fix code provided by OlegZhukov, set up ceils for baseDelay, maxBackoffTime and retriesAttempted to prevent potential overflow problems.

Description

Added three ceils for baseDelay, maxBackoffTime and retriesAttempted respectively. Restricted the exponentialDelayMillis from overflow via applying these ceils in calculation. Added unit tests for EqualJitterBackoffStrategy.java based on proposed test cases provided by OlegZhukov.
In addition, to make it easier to compare different Duration objects, two functions min and max are added in NumericUtils.java, corresponding tests are added too.

Motivation and Context

Before this modification, the exponentialDelay has a risk of overflow due to its type as Integer. Besides, baseDelay and maxBackoffTime are not checked if they will meet overflow problems while converting into Millis. So to fix these potential problems, we need to add some restrictions on these variables, as well as the calculation.

The open issue corresponding to this pull request is: #1453 .

Testing

Two new test classes are added in this pull request. One is the test class for EqualJitterBackoffStrategyTest.java, which includes unit tests for different values of baseDelay and maxBackoffTime. The other is for NumericUtils.java, testing whether the compare functions work well in different situations.

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 read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed
  • A short description of the change has been added to the CHANGELOG
  • 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

@codecov-io
Copy link

codecov-io commented Feb 27, 2020

Codecov Report

Merging #1673 into master will decrease coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1673      +/-   ##
============================================
- Coverage     74.48%   74.48%   -0.01%     
  Complexity      909      909              
============================================
  Files           960      960              
  Lines         30376    30316      -60     
  Branches       2390     2371      -19     
============================================
- Hits          22626    22580      -46     
+ Misses         6615     6598      -17     
- Partials       1135     1138       +3
Flag Coverage Δ Complexity Δ
#unittests 74.48% <ø> (-0.01%) 909 <ø> (ø)
Impacted Files Coverage Δ Complexity Δ
.../awssdk/http/apache/internal/net/SdkSslSocket.java 36.36% <0%> (-22.73%) 0% <0%> (ø)
...nio/netty/internal/OldConnectionReaperHandler.java 81.81% <0%> (-9.1%) 0% <0%> (ø)
...mazon/awssdk/core/internal/retry/RetryHandler.java 93.18% <0%> (-2.28%) 0% <0%> (ø)
...ery/internal/marshall/QueryMarshallerRegistry.java 77.77% <0%> (-2.23%) 0% <0%> (ø)
...awssdk/codegen/poet/client/specs/ProtocolSpec.java 81.57% <0%> (-2.15%) 0% <0%> (ø)
.../amazon/awssdk/http/apache/ProxyConfiguration.java 49.03% <0%> (-0.97%) 0% <0%> (ø)
...signer/internal/AwsChunkedEncodingInputStream.java 46.62% <0%> (-0.68%) 0% <0%> (ø)
...internal/client/DefaultDynamoDbEnhancedClient.java 65.38% <0%> (-0.66%) 13% <0%> (ø)
...ternal/marshall/JsonProtocolMarshallerBuilder.java 92.3% <0%> (-0.55%) 0% <0%> (ø)
...awssdk/regions/internal/util/EC2MetadataUtils.java 38.2% <0%> (-0.3%) 0% <0%> (ø)
... and 33 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cc88c19...ee4a458. Read the comment docs.

@Quanzzzz Quanzzzz force-pushed the backoff-overflow-fixing branch from 780e563 to 0b1606c Compare February 28, 2020 00:39
@Quanzzzz Quanzzzz force-pushed the backoff-overflow-fixing branch 2 times, most recently from 3e89194 to 0e723e5 Compare February 28, 2020 06:38
Copy link
Contributor

@spfink spfink left a comment

Choose a reason for hiding this comment

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

Note in the future if you update branch through GitHub you don't need to rebase the commit locally. Please make sure the other files are not actually being modified before merging

@Quanzzzz Quanzzzz force-pushed the backoff-overflow-fixing branch from 0e723e5 to cc88c19 Compare February 29, 2020 00:39
@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 2, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 2 Security Hotspots to review)
Code Smell A 1 Code Smell

No Coverage information No Coverage information
No Duplication information No Duplication information

@zoewangg zoewangg merged commit 9f7afe9 into aws:master Mar 2, 2020
aws-sdk-java-automation added a commit that referenced this pull request Sep 7, 2021
…03cf95c22

Pull request: release <- staging/78fb9957-186a-446f-b932-be403cf95c22
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.

4 participants