bps: prevent missing matras head view changes#11980
Merged
sergepetrenko merged 1 commit intotarantool:masterfrom Oct 31, 2025
Merged
bps: prevent missing matras head view changes#11980sergepetrenko merged 1 commit intotarantool:masterfrom
sergepetrenko merged 1 commit intotarantool:masterfrom
Conversation
50fc9c3 to
747d248
Compare
Contributor
Author
|
Discussed offline and decided to keep it similar to the BPS vector for now. |
8c4162b to
ee1dfc6
Compare
nshy
approved these changes
Oct 27, 2025
Astronomax
approved these changes
Oct 27, 2025
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 tarantool#11857 Closes tarantool#11979 NO_DOC=bugfix NO_CHANGELOG=was not released
ee1dfc6 to
18c422f
Compare
Contributor
Author
Fixed a typo.--- a/src/lib/salad/bps_tree.h
+++ b/src/lib/salad/bps_tree.h
@@ -3193,7 +3193,7 @@ bps_tree_garbage_pop(struct bps_tree_common *tree, bps_tree_block_id_t *id)
* an existing leaf to link it with the new one, and then
* update the new leaf's `next_id` (which updates data of
* the read view by the pointer returned here instead of
- * new CoWed data). This case is easily fixable bit let's
+ * new CoWed data). This case is easily fixable but let's
* fix it here the same way as it was fixed in BPS vector,
* as keeping this function non-CoW makes its usage error-
* prone. |
Collaborator
|
Successfully created backport PR for |
Collaborator
|
Successfully created backport PR for |
Collaborator
|
Successfully created backport PR for |
Collaborator
Backport summary
|
Contributor
Author
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.
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