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

fix: correct token bucket delays when experiencing system time jumps #810

Merged
merged 1 commit into from
Feb 23, 2023

Conversation

ianbotsf
Copy link
Contributor

Issue #

Closes #805

Description of changes

As noted in #805 the retry token bucket calculation is susceptible to changes in system time. Replace the Clock implementation with a Kotlin TimeSource.Monotonic, which offers intra-moment comparison capable of withstanding system time changes.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ianbotsf ianbotsf requested a review from a team as a code owner February 23, 2023 00:22
@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

No Coverage information No Coverage information
0.0% 0.0% Duplication

*/
public class StandardRetryTokenBucket(
@OptIn(ExperimentalTime::class)
Copy link
Contributor

Choose a reason for hiding this comment

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

We've gotten ourselves in trouble in the past by using experimental stdlib features (awslabs/aws-sdk-kotlin#622, awslabs/aws-sdk-kotlin#736). I don't have a better suggestion here but something to consider w.r.t any versioning policy/strategy we define.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Discussed offline and decided to keep usage of this type for now, despite it being marked as experimental. I've added a task aws-sdk-kotlin#860 to track revisiting all usages of experimental/unstable APIs before GA.

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.

When system time is incorrect and in the past coroutine can be suspended for a long period of time
3 participants