Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vinyl: fix index build crash on invalid UPSERT #10027

Merged

Conversation

locker
Copy link
Member

@locker locker commented May 17, 2024

Like UPDATE, UPSERT must not modify primary key parts. Unlike UPDATE, such an invalid UPSERT statement doesn't fail (raise an error) - we just log the error and ignore the statement. The problem is, we don't clear txn_stmt. As a result, if we're currently building a new index, the on_replace trigger installed by the build procedure will try to process this statement, triggering the assertion in the transaction manager that doesn't expect any statements in a secondary index without the corresponding statement in the primary index:

./src/box/vy_tx.c:728: vy_tx_prepare: Assertion `lsm->space_id == current_space_id' failed.

Let's fix this by clearing the txn_stmt corresponding to a skipped UPSERT.

Note, this also means that on_replace triggers installed by the user won't run on invalid UPSERT (hence test/vinyl/on_replace.result update), but this is consistent with the memtx engine, which doesn't run them in this case, either.

Closes #10026

@locker locker requested a review from a team as a code owner May 17, 2024 13:35
@coveralls
Copy link

coveralls commented May 17, 2024

Coverage Status

coverage: 87.105% (+0.004%) from 87.101%
when pulling e582882 on locker:vy-index-build-crash-on-invalid-upsert-fix
into 39af9fb
on tarantool:master
.

@locker locker requested a review from nshy May 17, 2024 14:01
@ligurio
Copy link
Member

ligurio commented May 17, 2024

There is no regression test in the patch. I cannot guarantee that fuzzing test will cover patches for all found bugs. So there is a non-zero possibility that bug #10026 will happen again in the future.

Like UPDATE, UPSERT must not modify primary key parts. Unlike UPDATE,
such an invalid UPSERT statement doesn't fail (raise an error) - we
just log the error and ignore the statement. The problem is, we don't
clear txn_stmt. As a result, if we're currently building a new index,
the on_replace trigger installed by the build procedure will try to
process this statement, triggering the assertion in the transaction
manager that doesn't expect any statements in a secondary index without
the corresponding statement in the primary index:

  ./src/box/vy_tx.c:728: vy_tx_prepare:
    Assertion `lsm->space_id == current_space_id' failed.

Let's fix this by clearing the txn_stmt corresponding to a skipped
UPSERT.

Note, this also means that on_replace triggers installed by the user
won't run on invalid UPSERT (hence test/vinyl/on_replace.result update),
but this is consistent with the memtx engine, which doesn't run them
in this case, either.

Closes tarantool#10026

NO_DOC=bug fix
@locker locker force-pushed the vy-index-build-crash-on-invalid-upsert-fix branch from 87b72b6 to e582882 Compare May 18, 2024 09:56
@locker
Copy link
Member Author

locker commented May 18, 2024

There is no regression test in the patch. I cannot guarantee that fuzzing test will cover patches for all found bugs. So there is a non-zero possibility that bug #10026 will happen again in the future.

Added a regression test.

Copy link
Contributor

@nshy nshy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@nshy nshy assigned locker and unassigned nshy May 20, 2024
@locker locker added the full-ci Enables all tests for a pull request label May 20, 2024
@locker
Copy link
Member Author

locker commented May 20, 2024

The integration/php-queue test failure isn't caused by this fix.

@locker locker merged commit 5ac0d26 into tarantool:master May 20, 2024
92 of 93 checks passed
@locker locker deleted the vy-index-build-crash-on-invalid-upsert-fix branch May 20, 2024 11:42
@locker
Copy link
Member Author

locker commented May 20, 2024

Cherry-picked to 2.11 and 3.1.

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.

Vinyl: Assertion `lsm->space_id == current_space_id' is triggered
5 participants