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

Atomicity of space:drop() #8667

Closed
mkostoevr opened this issue May 17, 2023 · 2 comments
Closed

Atomicity of space:drop() #8667

mkostoevr opened this issue May 17, 2023 · 2 comments
Assignees
Labels
box The database and relevant APIs bug Something isn't working

Comments

@mkostoevr
Copy link
Contributor

Bug description

box.schema.space.drop can leave the database in an inconsistent state if one of its steps failed.

  • OS: Linux
  • OS Version: Ubuntu 22.04.2 LTS
  • Architecture: amd64

Tarantool version: current HEAD (as of 17 may 2023).

Steps to reproduce

  1. Configure the tarantool box: box.cfg{}.
  2. Attempt to drop _vpriv system space (will fail): box.space._vpriv:drop().
  3. Attempt to drop _vinyl_deferred_delete (should fail by the same reason, but... see below): box.space._vinyl_deferred_delete:drop().

Actual behavior

tarantool> box.space._vpriv:drop()
---
- error: Can't drop the primary key in a system space, space '_vpriv'
...

tarantool> box.space._vinyl_deferred_delete:drop()
---
- error: 'builtin/box/schema.lua:230: attempt to index field ''object'' (a nil value)'
...

Expected behavior

The first error is expected, but the second one is not.

Root cause

  1. On attempt to drop the _vpriv we drop all of its indexes starting from non-primary ones here: box.schema.space.drop+25, so the space has no indexes anymore.
  2. Then we try to get its object index on _vinyl_deferred_delete drop here: box.schema.space.drop+27->revoke_object_privs+3. But since we have deleted all non-primary indexes of the _vpriv before, tarantool fails with nil-access error.

Proposal

The box.schema.space.drop function should revert all the changes it made if any step is failed.

@mkostoevr mkostoevr added bug Something isn't working box The database and relevant APIs labels May 17, 2023
@mkostoevr mkostoevr self-assigned this May 17, 2023
@olegrok
Copy link
Collaborator

olegrok commented May 19, 2023

Seems it's related to #4348

In case if drop will be atomic we have following case

tarantool> box.atomic(function() box.space._vpriv:drop() end)
---
- error: Can't drop the primary key in a system space, space '_vpriv'
...

tarantool> box.atomic(function() box.space._vinyl_deferred_delete:drop() end)
---
...

@mkostoevr
Copy link
Contributor Author

Seems it's related to #4348

Yes, it is.

In case if drop will be atomic we have following case

tarantool> box.atomic(function() box.space._vpriv:drop() end)
---
- error: Can't drop the primary key in a system space, space '_vpriv'
...

tarantool> box.atomic(function() box.space._vinyl_deferred_delete:drop() end)
---
...

Yes, and the behavior is desirable. Now you can drop the _vinyl_deferred_delete space, but it will be fixed if the related PR (#8623) will be merged.

Closed the issue as duplicate of #4348.

@mkostoevr mkostoevr closed this as not planned Won't fix, can't repro, duplicate, stale May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
box The database and relevant APIs bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants