Repository navigation
Process deletes before adds when committing OrderedList state updates. - #40659
Conversation
…. Otherwise we delete the newly added id from the idTracker.
There was a problem hiding this comment.
📋 Review Summary
This PR fixes a bug in WindmillOrderedList.persistDirectly where pendingAdds were committed to IdTracker before pendingDeletes, causing range deletions in the same work item to overwrite sub-range deletion tracking or wipe out ID tracking for elements added after clearRange. Processing pendingDeletes before pendingAdds matches the logical order of operations since clearRange already evicts prior in-memory pendingAdds in the deleted range.
🔍 General Feedback
- The fix in
WindmillOrderedListis clean and accurately preservesIdTrackerstate across overlappingclearRangeandaddoperations within the same work item. - The new unit test
testOrderedListDeleteRangeThenAddPersistthoroughly covers both partial sub-range deletions followed by adds and full 5-minute bucket clears followed by adds.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #40659 +/- ##
=============================================
+ Coverage 56.16% 75.83% +19.66%
Complexity 2288 2288
=============================================
Files 1124 259 -865
Lines 178336 14459 -163877
Branches 1489 1487 -2
=============================================
- Hits 100170 10965 -89205
+ Misses 75645 2792 -72853
+ Partials 2521 702 -1819
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Assigning reviewers: R: @shunping added as fallback since no labels match configuration Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
| cleared = false; | ||
| } | ||
|
|
||
| if (!pendingDeletes.isEmpty()) { |
There was a problem hiding this comment.
I agree that we need to apply pendingDeletes before pendingAdds. When clearRange() is called, it already clears any existing pendingAdds that fall within the deleted range (see the logic in clearRange()).
Therefore, if there is a remaining pendingAdd that overlaps with a pendingDelete range, it means the add operation occurred after the clear operation. Applying the deletes first ensures that these subsequent additions are correctly preserved.
Before this PR, we add an id to the IdTracker and then delete it even if the delete operation on the ordered list state happened before the add. Added a test to demonstrate this error (and the fix).