[backport 3.3] bps: prevent missing matras head view changes#12008
Merged
sergepetrenko merged 1 commit intorelease/3.3from Oct 31, 2025
Merged
[backport 3.3] bps: prevent missing matras head view changes#12008sergepetrenko merged 1 commit intorelease/3.3from
sergepetrenko merged 1 commit intorelease/3.3from
Conversation
We've removed CoW'ing of garbage blocks for creating new inner/leaf blocks in commit 52b3d4b ("salad: reserve block before bps_tree_insert_first_elem") as the blocks are not required to be preserved in views and can be used without CoW. The problem is that in some circumstances this approach can lead to a tricky problem: if we've created a block, CoW'ed another one and then update values of the created one, the new block could've been CoW'ed by the previous `matras_touch` (as the blocks are located in extents of greater size than the blocks themselves). So following updates in the created block gone into the view while the current matras head had the old view's values remained. The problem is that if we don't touch the garbage on block creation, we need to make sure there's no any `matras_touch` between the block creation and the last assignment of its field. We could fix the only place where the guarantee is not preserved: the leaf insert routine, but let's keep the tree similar to the BPS vector and simply revert the change and touch popped garbage blocks too. Since now the garbage pop invokes CoW, we might need to reserve more memory for touches, as some new garbage blocks can be allocated on the `bps_vec_reserve_blocks`, but other ones can be existing in the vector previously, and, for these ones, we must reserve touches. Also, one more touch might be required if a new block allocated on reserve. Removed the target leaf touch from the `bps_tree_process_insert_leaf` by the way as it's not required cause the leaf is touched on lookup. Follows-up #11857 Closes #11979 NO_DOC=bugfix NO_CHANGELOG=was not released (cherry picked from commit 24cdd89)
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.
(This PR is a backport of #11980 to
release/3.3to a future3.3.4release.)We've removed CoW'ing of garbage blocks for creating new inner/leaf blocks in commit 52b3d4b ("salad: reserve block before bps_tree_insert_first_elem") as the blocks are not required to be preserved in views and can be used without CoW.
The problem is that in some circumstances this approach can lead to a tricky problem: if we've created a block, CoW'ed another one and then update values of the created one, the new block could've been CoW'ed by the previous
matras_touch(as the blocks are located in extents of greater size than the blocks themselves). So following updates in the created block gone into the view while the current matras head had the old view's values remained.The problem is that if we don't touch the garbage on block creation, we need to make sure there's no any
matras_touchbetween the block creation and the last assignment of its field. We could fix the only place where the guarantee is not preserved: the leaf insert routine, but let's keep the tree similar to the BPS vector and simply revert the change and touch popped garbage blocks too.Since now the garbage pop invokes CoW, we might need to reserve more memory for touches, as some new garbage blocks can be allocated on the
bps_vec_reserve_blocks, but other ones can be existing in the vector previously, and, for these ones, we must reserve touches. Also, one more touch might be required if a new block allocated on reserve.Removed the target leaf touch from the
bps_tree_process_insert_leafby the way as it's not required cause the leaf is touched on lookup.Follows-up #11857
Closes #11979
NO_DOC=bugfix
NO_CHANGELOG=was not released