Merged
Conversation
xuniq
approved these changes
Feb 17, 2025
nshy
approved these changes
Feb 17, 2025
If a read iterator skips a DELETE statement from the current transaction write set, it clears the last cached entry so as not to create a cache chain jumping over the old key version, which is still visible by other transactions. The problem is that it doesn't clear the is_first_cached flag. As a result, if there happens to be a DELETE statement in the transaction write set preceding the first returned tuple, a read iterator will still create a so-called "boundary" cache chain. We must clear the flag to avoid that. Part of tarantool#11079 NO_DOC=bug fix NO_CHANGELOG=added later
The tuple cache can store chains. If a read iterator sees a chain, it may skip deeper sources assuming there's nothing there. The problem with cache chains is that we don't store their LSNs anywhere, as a result a read iterator operating in a read view may erroneously skip tuples deleted after the read view was created. Let's fix this issue by storing the LSNs of the left- and right-adjacent chains in each cache node. The LSN is initialized by the read iterator as the max LSN among all skipped DELETE statements lying in the chain. Part of tarantool#11079 NO_DOC=bug fix NO_CHANGELOG=added later
Each cache chain stores the max LSN among all DELETE statements that are known to fall in the chain. This LSN is required so that an older read view can ignore the chain, otherwise it could skip tuples deleted after the read view was created (see the previous commit). The problem is, apart from regular DELETE statements, there may be so called "deferred" ones. Deferred DELETE statements aren't written to secondary indexes immediately on commit - this is done later, when the primary index is compacted. If we don't find the corresponding full tuple in the primary index by a partial tuple key fetched from a secondary index, we skip it and create a cache chain leaping over it so that we don't read it again on the next scan. We don't take into account the deferred DELETE LSN in this case, as a result, we face the same problem we fixed in the previous commit for regular DELETEs. To avoid that, let's keep track of the max LSN among all skipped statements and use it for the cache chain. Note, we have to patch vy_point_lookup() so that it can keep a DELETE statement instead of returning NULL - we need it to extract its LSN for the cache. This changes the stats a bit hence the vinyl/deferred_delete test update. Closes tarantool#11079 NO_DOC=bug fix
bb548e8 to
e6d98cf
Compare
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.
This commit fixes a few issues in the tuple cache when a transaction operating in a read view could skip tuples deleted after the read view was created.
Closes #11079