Skip to content

Fix intermittent test failure in getItem_set_eventualConsistent due to eventual consistency #6303

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 1 commit into from
Jul 29, 2025

Conversation

joviegas
Copy link
Contributor

Fix intermittent test failure in getItem_set_eventualConsistent due to eventual consistency

Motivation and Context

The getItem_set_eventualConsistent test was intermittently failing with the following error:

java.lang.AssertionError: 
Expecting actual:
  0.5
to be close to:
  10.0
by less than 1.0 but difference was 9.5.

This failure occurs because the test performs a DynamoDB read immediately after a write operation. Due to DynamoDB's eventually consistent read model, the item may not be immediately available, resulting in a "not found" response that consumes only 0.5 RCUs instead of the expected 10 RCUs for an 80KB item.

Modifications

  • Added retry logic to handle eventual consistency delays in DynamoDB
  • Implemented a single retry with 200ms delay when the initial read returns null
  • Added assertion with descriptive failure message to clearly indicate when item propagation fails
  • Added null check before proceeding with capacity assertions to prevent misleading test failures

The fix ensures the test waits for item propagation before validating consumed capacity, eliminating race conditions while maintaining the test's purpose of verifying eventually consistent read capacity consumption.

Testing

  • Ran the test multiple times locally to verify it no longer fails intermittently

Screenshots (if appropriate)

License

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

@joviegas joviegas requested a review from a team as a code owner July 28, 2025 20:50
@joviegas joviegas changed the title Handle eventual consistency test case to make sure to wait for some time so that item is eventually available Fix intermittent test failure in getItem_set_eventualConsistent due to eventual consistency Jul 28, 2025
Copy link

@joviegas joviegas added this pull request to the merge queue Jul 29, 2025
Merged via the queue into master with commit bfb1030 Jul 29, 2025
36 of 38 checks passed
Copy link

This pull request has been closed and the conversation has been locked. Comments on closed PRs are hard for our team to see. If you need more assistance, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants