Conversation
Add a field to keep track of the previous amount of leaves within the page and its children in order to extract a delta of new leaves (either negative or positive) to properly propagate the information upwards to other pages.
rphmeier
approved these changes
Oct 8, 2025
There are rare occasions when the left worker creates a page that was previously elided by the right worker. In this case, this fix ensures that the page is properly updated without deleting it (which was happening before). The reason this happens is that the leaf and branch stages, while handling merges, update the cutoff of each node. The cutoff updated after the deletion of a node can also be used as a new high range sent to the left worker. Thus, the left worker thinks that everything between the last modified page sent by the right worker and the new high range has free keys to be used as separators, and those separators could have previously been eliminated by the right worker.
Stop using `or`, which eagerly evaluates, and instead use `or_else`.
| // cannot be removed. | ||
| parent_stack_page | ||
| .children_leaves_counter | ||
| .replace(new_parent_children_leaves_counter.try_into().unwrap()); |
There was a problem hiding this comment.
The unwrap() call requires explicit justification. While lines 892-894 provide general context about the expectation that page and children deltas cannot exceed the parent counter when negative, this specific try_into().unwrap() conversion lacks documentation explaining why the conversion from i64 to u64 will never fail. Add a comment above this line or include the justification in the unwrap message to explain why new_parent_children_leaves_counter is guaranteed to be non-negative.
Suggested change
| .replace(new_parent_children_leaves_counter.try_into().unwrap()); | |
| // new_parent_children_leaves_counter is guaranteed to be non-negative here | |
| // because we've already verified that the page and children deltas cannot | |
| // exceed the parent counter when negative | |
| .replace(new_parent_children_leaves_counter.try_into().expect( | |
| "Counter must be non-negative after delta application", | |
| )); |
Spotted by Graphite Agent (based on custom rule: Custom rules)
Is this helpful? React 👍 or 👎 to let us know.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.