vinyl: do not reset cache link LSN on partial key lookup#11297
Merged
locker merged 1 commit intotarantool:masterfrom Mar 26, 2025
Merged
vinyl: do not reset cache link LSN on partial key lookup#11297locker merged 1 commit intotarantool:masterfrom
locker merged 1 commit intotarantool:masterfrom
Conversation
Since commit e8109b2 ("vinyl: ignore cache chains with invisible DELETEs") each cache node stores the LSNs of the left and right links. They are used to ignore links that are invisible from the current read view (created after the read view was opened). We update the LSN not only when we link two nodes together but also when we update the node's boundary level. This is incorrect if the node is linked. For example, suppose we have an index over two fields that contains tuples {0,2} and {2,0} and there's a transaction that was sent to a read view. Now another transaction inserts {0,1} and deletes {0,2}, then selects all tuples. This results in creation of two interlinked cache nodes: {0,1} and {2,0}. The link is invisible from the read view: since we skipped DELETE{0,2}, its LSN equals the LSN of the DELETE statement, which is greater than the read view LSN. However, if we now select GT{1}, we will update the boundary level of the node storing {2,0} from 2 to 1 and reset its LSN to 0 because we didn't skip any DELETE statements. As a result, if the transaction operating in the read view tries to select GT{0,1}, it will find {2,0}, see that it's left-linked and the link LSN is 0, and return it right away, skipping {0,2}, which is visible from the read view. To fix this issue, let's skip the boundary level update if the node is linked. It doesn't make sense anyway because the boundary level is used only for unlinked nodes, see vy_cache_iterator_is_stop(). Follow-up tarantool#11079 Closes tarantool#11294 NO_DOC=bug fix
xuniq
approved these changes
Mar 26, 2025
Member
Author
|
Cherry-picked to 2.11, 3.2, 3.3. |
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.
Since commit e8109b2 ("vinyl: ignore cache chains with invisible DELETEs") each cache node stores the LSNs of the left and right links. They are used to ignore links that are invisible from the current read view (created after the read view was opened). We update the LSN not only when we link two nodes together but also when we update the node's boundary level. This is incorrect if the node is linked.
For example, suppose we have an index over two fields that contains tuples {0,2} and {2,0} and there's a transaction that was sent to a read view. Now another transaction inserts {0,1} and deletes {0,2}, then selects all tuples. This results in creation of two interlinked cache nodes: {0,1} and {2,0}. The link is invisible from the read view: since we skipped DELETE{0,2}, its LSN equals the LSN of the DELETE statement, which is greater than the read view LSN. However, if we now select GT{1}, we will update the boundary level of the node storing {2,0} from 2 to 1 and reset its LSN to 0 because we didn't skip any DELETE statements. As a result, if the transaction operating in the read view tries to select GT{0,1}, it will find {2,0}, see that it's left-linked and the link LSN is 0, and return it right away, skipping {0,2}, which is visible from the read view.
To fix this issue, let's skip the boundary level update if the node is linked. It doesn't make sense anyway because the boundary level is used only for unlinked nodes, see
vy_cache_iterator_is_stop().Follow-up #11079
Closes #11294