Skip to content

fix(idempotency): return correct value from in-memory cache #2311

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

dreamorosi
Copy link
Contributor

Description of your changes

This PR fixes a bug in the Idempotency utility that caused retries performed while the utility's in-memory cache was enabled to be rejected as "already in-progress" rather than returning the value from the previous execution.

Due to this bug happening exclusively on repeated (aka subsequent) idempotent requests it's highly unlikely that customers might have experienced data loss but instead they would have observed an artificially high number of IdempotencyAlreadyInProgressError errors as if the previous execution was not yet complete, which is still not great.

The PR addresses the bug by returning the value from cache whenever one is found. It also addresses a gap in our tests that was evidenced by us not catching the bug by enabling the useLocalCache setting in some existing cases both in the unit & integration tests.

Related issues, RFCs

Issue number: #2309

Checklist

  • My changes meet the tenets criteria
  • I have performed a self-review of my own code
  • I have commented my code where necessary, particularly in areas that should be flagged with a TODO, or hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my change is effective and works
  • The PR title follows the conventional commit semantics

Breaking change checklist

Is it a breaking change?: NO

  • I have documented the migration process
  • I have added, implemented necessary warnings (if it can live side by side)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@dreamorosi dreamorosi self-assigned this Apr 3, 2024
@dreamorosi dreamorosi requested a review from a team April 3, 2024 14:26
@dreamorosi dreamorosi requested a review from a team as a code owner April 3, 2024 14:26
@dreamorosi dreamorosi linked an issue Apr 3, 2024 that may be closed by this pull request
@boring-cyborg boring-cyborg bot added idempotency This item relates to the Idempotency Utility tests PRs that add or change tests labels Apr 3, 2024
@pull-request-size pull-request-size bot added the size/M PR between 30-99 LOC label Apr 3, 2024
@github-actions github-actions bot added the bug Something isn't working label Apr 3, 2024
Copy link
Contributor

@am29d am29d left a comment

Choose a reason for hiding this comment

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

Great catch!

Copy link

sonarqubecloud bot commented Apr 5, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@am29d am29d merged commit b908aa1 into main Apr 5, 2024
10 checks passed
@am29d am29d deleted the 2309-bug-idempotency-in-memory-cache-doesnt-read-correct-value branch April 5, 2024 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working idempotency This item relates to the Idempotency Utility size/M PR between 30-99 LOC tests PRs that add or change tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: idempotency in-memory cache doesn't read correct value
2 participants