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

box: loose truncate check in case of foreign key 2.10 #8961

Conversation

alyapunov
Copy link
Contributor

In #7309 a truncation of a space that was referenced by foreign key from some other space was prohibited.

It appeared that this solution is too bothering since a user can't truncate a space even if he truncated referring space before that.

Fix it by allowing space truncate if referring spaces are empty. Also allow drop of the primary index in the same case with the same reason: logically the index along with all space data is not needed for consistency if there's no referring data.

Note that by design space truncate is implemented quite similar to space drop. Both delete all indexes, from secondary to primary. Since this patch allows deletion of the primary index (which is the action that actually deletes all data from the space), this patch changes the result of space drop too: the space remains alive with no indexes, while before this patch it remained alive with no secondary indexes but with present primary. In both cases the behaviour is quite strange and must be fixed in #4348. To make tests pass I had to perform drop in box.atomic manually.

Closes #8946

NO_DOC=bugfix

(cherry picked from commit 983a7ec)

(backport of #8947)

In tarantool#7309 a truncation of a space that was referenced by foreign
key from some other space was prohibited.

It appeared that this solution is too bothering since a user can't
truncate a space even if he truncated referring space before that.

Fix it by allowing space truncate if referring spaces are empty.
Also allow drop of the primary index in the same case with the
same reason: logically the index along with all space data is
not needed for consistency if there's no referring data.

Note that by design space truncate is implemented quite similar
to space drop. Both delete all indexes, from secondary to primary.
Since this patch allows deletion of the primary index (which is
the action that actually deletes all data from the space), this
patch changes the result of space drop too: the space remains
alive with no indexes, while before this patch it remained alive
with no secondary indexes but with present primary. In both cases
the behaviour is quite strange and must be fixed in tarantool#4348. To
make tests pass I had to perform drop in box.atomic manually.

Closes tarantool#8946

NO_DOC=bugfix

(cherry picked from commit 983a7ec)
@alyapunov alyapunov added the full-ci Enables all tests for a pull request label Aug 7, 2023
@alyapunov alyapunov changed the title box: loose truncate check in case of foreign key box: loose truncate check in case of foreign key 2.10 Aug 7, 2023
@coveralls
Copy link

Coverage Status

coverage: 85.242% (+0.02%) from 85.224% when pulling 9e099bf on alyapunov:gh-8946-foreign-key-disables-truncate-2.10 into 9f47089
on tarantool:release/2.10
.

@alyapunov alyapunov merged commit 6f6d1f6 into tarantool:release/2.10 Aug 7, 2023
142 checks passed
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.

None yet

2 participants