Skip to content

[backport 3.4] bps: prevent missing matras head view changes#12009

Merged
sergepetrenko merged 1 commit intorelease/3.4from
backport/release/3.4/11980
Oct 31, 2025
Merged

[backport 3.4] bps: prevent missing matras head view changes#12009
sergepetrenko merged 1 commit intorelease/3.4from
backport/release/3.4/11980

Conversation

@TarantoolBot
Copy link
Collaborator

@TarantoolBot TarantoolBot commented Oct 31, 2025

(This PR is a backport of #11980 to release/3.4 to a future 3.4.2 release.)


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

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)
@TarantoolBot TarantoolBot added the full-ci Enables all tests for a pull request label Oct 31, 2025
@TarantoolBot TarantoolBot changed the title [Backport release/3.4] bps: prevent missing matras head view changes [backport 3.4] bps: prevent missing matras head view changes Oct 31, 2025
@sergepetrenko sergepetrenko removed the full-ci Enables all tests for a pull request label Oct 31, 2025
@coveralls
Copy link

Coverage Status

coverage: 87.543% (-0.03%) from 87.572%
when pulling dbbe9da on backport/release/3.4/11980
into 43a21f6
on release/3.4
.

@sergepetrenko sergepetrenko merged commit 6e04b72 into release/3.4 Oct 31, 2025
47 of 60 checks passed
@sergepetrenko sergepetrenko deleted the backport/release/3.4/11980 branch October 31, 2025 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants