GeezerVison is showing github.com — [improve][ml] RangeCache refactoring: test race conditions and prevent endless loops by lhotari · Pull Request #22814 · apache/pulsar
Conversation
Motivation
Follow up on #22789. Test a few basic race conditions.
The solution in #22789 could lead to an endless loop. This PR fixes this problem.
Race conditions are logged with info level, for example:
2024-05-31T08:57:44,823 - INFO - [pool-2-thread-4:RangeCache@308] - Value was already released for key 59, removing entry without releasing the value
2024-05-31T08:57:44,824 - INFO - [pool-2-thread-4:RangeCache@308] - Value was already released for key 153, removing entry without releasing the value
2024-05-31T08:57:44,824 - INFO - [pool-2-thread-7:RangeCache@308] - Value was already released for key 153, removing entry without releasing the value
2024-05-31T08:57:44,824 - INFO - [pool-2-thread-8:RangeCache@308] - Value was already released for key 60, removing entry without releasing the value
2024-05-31T08:57:44,827 - INFO - [pool-2-thread-2:RangeCache@296] - Key 580 does not match the entry's value wrapper's key 660, removing entry by key without releasing the value
2024-05-31T08:57:44,827 - INFO - [pool-2-thread-3:RangeCache@296] - Key 226 does not match the entry's value wrapper's key 668, removing entry by key without releasing the value
2024-05-31T08:57:44,827 - INFO - [pool-2-thread-4:RangeCache@308] - Value was already released for key 741, removing entry without releasing the value
2024-05-31T08:57:44,829 - INFO - [pool-2-thread-6:RangeCache@308] - Value was already released for key 980, removing entry without releasing the value
2024-05-31T08:57:44,830 - INFO - [pool-2-thread-6:RangeCache@308] - Value was already released for key 1074, removing entry without releasing the value
2024-05-31T08:57:44,830 - INFO - [pool-2-thread-3:RangeCache@296] - Key 1088 does not match the entry's value wrapper's key 1358, removing entry by key without releasing the value
2024-05-31T08:57:44,911 - INFO - [main:RangeCache@337] - Value RangeCacheTest.RefString(s=1, matchingKey=123) does not match the key 1, removed entry without releasing the value
2024-05-31T08:57:44,912 - INFO - [main:RangeCache@308] - Value was already released for key 1, removing entry without releasing the value
Modifications
- test some invalid entry cases which could be a result of race conditions
- prevent endless loops in
evictLeastAccessedEntries, evictLEntriesBeforeTimestamp and clear.
- invalid entries cannot be skipped since
.firstEntry() method is used for iterating in removal. If the entry isn't removed and persists, it causes the endless loop.
- add logic for skipping invalid entries for
removeRange
Documentation
-
doc
-
doc-required
-
doc-not-needed
-
doc-complete
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
- prevent getting the value of a different key if the wrapper has been recycled
This was referenced May 31, 2024
- consuming entries shouldn't impact cache size
|
❌ Patch coverage is 78.12500% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.25%. Comparing base (bbc6224) to head (bb1689c).
⚠️ Report is 1269 commits behind head on master.
Additional details and impacted files

@@ Coverage Diff @@
## master #22814 +/- ##
============================================
- Coverage 73.57% 73.25% -0.33%
+ Complexity 32624 2511 -30113
============================================
Files 1877 1889 +12
Lines 139502 141692 +2190
Branches 15299 15553 +254
============================================
+ Hits 102638 103792 +1154
- Misses 28908 29877 +969
- Partials 7956 8023 +67
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 389 files with indirect coverage changes
🚀 New features to boost your workflow:
- ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
merlimat
merlimat approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|