Skip to content

fix(cache): DynamoDBCache._clear only clears the first scan page#186

Merged
tomasvotava merged 2 commits into
masterfrom
fix/dynamodb-cache-clear-pagination
May 19, 2026
Merged

fix(cache): DynamoDBCache._clear only clears the first scan page#186
tomasvotava merged 2 commits into
masterfrom
fix/dynamodb-cache-clear-pagination

Conversation

@tomasvotava
Copy link
Copy Markdown
Owner

Closes #155

Paginates the scan on LastEvaluatedKey/ExclusiveStartKey until exhausted (typed via ScanInputTableScanTypeDef, mirroring DynamoDBStore._iter_all_keys) so tables larger than the ~1 MB scan page are fully cleared.

Tests: existing dynamodb clear contract + new monkeypatched pagination test (2 passed). All gates green.

🤖 Generated with Claude Code

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the DynamoDB cache adapter's _clear method to properly handle pagination using LastEvaluatedKey, ensuring all items are deleted from large tables. It also optimizes the scan operation by using a ProjectionExpression to retrieve only the necessary keys. A new test case was added to verify the pagination logic; however, feedback suggests enhancing the test's mock implementation to explicitly assert that the ExclusiveStartKey is correctly passed in subsequent scan calls.

Comment thread tests/infrastructure/test_cache.py
@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.61%. Comparing base (bcbfec9) to head (3a6da74).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #186      +/-   ##
==========================================
+ Coverage   87.59%   87.61%   +0.02%     
==========================================
  Files          57       57              
  Lines        2927     2932       +5     
==========================================
+ Hits         2564     2569       +5     
  Misses        363      363              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

tomasvotava added a commit that referenced this pull request May 19, 2026
Addresses gemini-code-assist review on PR #186: the mock returned page 2 unconditionally, so the test passed even if _clear failed to thread LastEvaluatedKey -> ExclusiveStartKey. Now assert no cursor on the first scan and the prior page's key on subsequent scans, so the pagination logic is actually exercised.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
tomasvotava and others added 2 commits May 19, 2026 20:04
Paginate the scan on LastEvaluatedKey/ExclusiveStartKey until exhausted (typed via ScanInputTableScanTypeDef, mirroring DynamoDBStore._iter_all_keys) so tables larger than the ~1 MB scan page are fully cleared.

Closes #155

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Addresses gemini-code-assist review on PR #186: the mock returned page 2 unconditionally, so the test passed even if _clear failed to thread LastEvaluatedKey -> ExclusiveStartKey. Now assert no cursor on the first scan and the prior page's key on subsequent scans, so the pagination logic is actually exercised.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@tomasvotava tomasvotava force-pushed the fix/dynamodb-cache-clear-pagination branch from 7915415 to 3a6da74 Compare May 19, 2026 18:04
@tomasvotava tomasvotava merged commit 3226d80 into master May 19, 2026
20 checks passed
@tomasvotava tomasvotava deleted the fix/dynamodb-cache-clear-pagination branch May 19, 2026 18:11
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.

fix(cache): DynamoDBCache._clear only clears the first scan page

1 participant