Skip to content

vinyl: don't create cache chain over unconfirmed deferred DELETE#11168

Merged
locker merged 1 commit intotarantool:masterfrom
locker:vy-deferred-delete-rollback-fix
Feb 19, 2025
Merged

vinyl: don't create cache chain over unconfirmed deferred DELETE#11168
locker merged 1 commit intotarantool:masterfrom
locker:vy-deferred-delete-rollback-fix

Conversation

@locker
Copy link
Member

@locker locker commented Feb 18, 2025

While scanning a non-unique secondary index of a vinyl space, we skip a tuple if there's no match for it in the primary index because it means that the tuple was overwritten by a newer statement but the secondary index DELETE was deferred until compaction. We still create a cache chain link in this case so that we skip the overwritten tuple when we scan the secondary index next time. We do it even if the overwriting statement is unconfirmed (not yet written to WAL), which is actually incorrect. The problem is that if the overwriting statement is rolled back on a WAL write error, the chain created in the secondary index cache won't be broken because nothing was actually written to the secondary index (DELETE was deferred) therefore there's nothing to roll back therefore there's nothing to invalidate the cache by. As a result, the tuple that the user attempted to delete but failed due to a WAL error will become inaccessible via the secondary index because of the stale cache chain.

Fix this issue by disabling creation of a cache chain link in case the read iterator skipped an unconfirmed deferred DELETE statement.

Closes #11140

While scanning a non-unique secondary index of a vinyl space, we skip
a tuple if there's no match for it in the primary index because it means
that the tuple was overwritten by a newer statement but the secondary
index DELETE was deferred until compaction. We still create a cache
chain link in this case so that we skip the overwritten tuple when
we scan the secondary index next time. We do it even if the overwriting
statement is unconfirmed (not yet written to WAL), which is actually
incorrect. The problem is that if the overwriting statement is rolled
back on a WAL write error, the chain created in the secondary index
cache won't be broken because nothing was actually written to the
secondary index (DELETE was deferred) therefore there's nothing to
roll back therefore there's nothing to invalidate the cache by.
As a result, the tuple that the user attempted to delete but failed
due to a WAL error will become inaccessible via the secondary index
because of the stale cache chain.

Fix this issue by disabling creation of a cache chain link in case
the read iterator skipped an unconfirmed deferred DELETE statement.

Closes tarantool#11140

NO_DOC=bug fix
@locker locker requested a review from a team as a code owner February 18, 2025 16:14
@coveralls
Copy link

Coverage Status

coverage: 87.425% (-0.006%) from 87.431%
when pulling 7cc811a on locker:vy-deferred-delete-rollback-fix
into 153463d
on tarantool:master
.

@locker locker requested a review from nshy February 18, 2025 17:12
@nshy nshy assigned locker and unassigned nshy Feb 19, 2025
@locker locker added the full-ci Enables all tests for a pull request label Feb 19, 2025
@locker locker merged commit 74f45f4 into tarantool:master Feb 19, 2025
94 of 95 checks passed
@locker locker deleted the vy-deferred-delete-rollback-fix branch February 19, 2025 15:54
@locker
Copy link
Member Author

locker commented Feb 19, 2025

Cherry-picked to 2.11, 3.2, 3.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-ci Enables all tests for a pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tuple missing in secondary index after WAL rollback with enabled deferred DELETEs

4 participants