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

Make all box.schema functions transactional #4348

Closed
locker opened this issue Jul 15, 2019 · 0 comments · Fixed by #8751
Closed

Make all box.schema functions transactional #4348

locker opened this issue Jul 15, 2019 · 0 comments · Fixed by #8751
Assignees
Labels
3.0 Target is 3.0 and all newer release/master branches app ddl feature A new functionality

Comments

@locker
Copy link
Member

locker commented Jul 15, 2019

Use box.begin() and box.commit() in all DDL functions exported to Lua, like box.schema.space.create() or box.schema.user.grant().

Follow-up #4083

@locker locker added feature A new functionality ddl app labels Jul 15, 2019
@kyukhin kyukhin added this to the 2.3.0 milestone Jul 15, 2019
kshcherbatov added a commit that referenced this issue Aug 5, 2019
The _func_index space trigger used to reject an insertion of a
tuple that defines an invalid functional index.
As insertion in _index space had been completed before, a garbage
is kept in _index space in such case.

We need to do something with the yelding _func_index trigger(that
rebuilds an index) to wrap all index creation operation in DDL
transaction in further patches (because only the first DDL
operation may yeld now).

This problem could be trivially solved with preparatory
initialization of index_def function ponter: the memtx_tree
index construction would perform all required job in such case.
Therefore the following index rebuild in _func_index trigger
becomes redundant and should be omitted.

In other words, a trivial prefetch operation makes possible
a transactional index creation (with space:create_index operation).

As for index construction during recovery (a lack of function
cache during recovery was the main motivation to introduce
_func_index space), it's workflow is kept unchanged.

Follow up #1250
Needed for #4348
Closes #4401
kshcherbatov added a commit that referenced this issue Aug 5, 2019
The _func_index space trigger used to reject an insertion of a
tuple that defines an invalid functional index.
As insertion in _index space had been completed before, a garbage
is kept in _index space in such case.

We need to do something with the yelding _func_index trigger(that
rebuilds an index) to wrap all index creation operation in DDL
transaction in further patches (because only the first DDL
operation may yeld now).

This problem could be trivially solved with preparatory
initialization of index_def function ponter: the memtx_tree
index construction would perform all required job in such case.
Therefore the following index rebuild in _func_index trigger
becomes redundant and should be omitted.

In other words, a trivial prefetch operation makes possible
a transactional index creation (with space:create_index operation).

As for index construction during recovery (a lack of function
cache during recovery was the main motivation to introduce
_func_index space), it's workflow is kept unchanged.

Follow up #1250
Needed for #4348
Closes #4401
kshcherbatov added a commit that referenced this issue Aug 6, 2019
The _func_index space trigger used to reject an insertion of a
tuple that defines an invalid functional index.
As insertion in _index space had been completed before, a garbage
is kept in _index space in such case.

We need to do something with the yelding _func_index trigger(that
rebuilds an index) to wrap all index creation operation in DDL
transaction in further patches (because only the first DDL
operation may yeld now).

This problem could be trivially solved with preparatory
initialization of index_def function ponter: the memtx_tree
index construction would perform all required job in such case.
Therefore the following index rebuild in _func_index trigger
becomes redundant and should be omitted.

In other words, a trivial prefetch operation makes possible
a transactional index creation (with space:create_index operation).

As for index construction during recovery (a lack of function
cache during recovery was the main motivation to introduce
_func_index space), it's workflow is kept unchanged.

Follow up #1250
Needed for #4348
Closes #4401
kshcherbatov added a commit that referenced this issue Aug 6, 2019
The _func_index space trigger used to reject an insertion of a
tuple that defines an invalid functional index.
As insertion in _index space had been completed before, a garbage
is kept in _index space in such case.

We need to do something with the yelding _func_index trigger(that
rebuilds an index) to wrap all index creation operation in DDL
transaction in further patches (because only the first DDL
operation may yeld now).

This problem could be trivially solved with preparatory
initialization of index_def function ponter: the memtx_tree
index construction would perform all required job in such case.
Therefore the following index rebuild in _func_index trigger
becomes redundant and should be omitted.

In other words, a trivial prefetch operation makes possible
a transactional index creation (with space:create_index operation).

As for index construction during recovery (a lack of function
cache during recovery was the main motivation to introduce
_func_index space), it's workflow is kept unchanged.

Follow up #1250
Needed for #4348
Closes #4401
locker pushed a commit that referenced this issue Aug 6, 2019
The _func_index space trigger used to reject an insertion of a
tuple that defines an invalid functional index.
As insertion in _index space had been completed before, a garbage
is kept in _index space in such case.

We need to do something with the yelding _func_index trigger(that
rebuilds an index) to wrap all index creation operation in DDL
transaction in further patches (because only the first DDL
operation may yeld now).

This problem could be trivially solved with preparatory
initialization of index_def function ponter: the memtx_tree
index construction would perform all required job in such case.
Therefore the following index rebuild in _func_index trigger
becomes redundant and should be omitted.

In other words, a trivial prefetch operation makes possible
a transactional index creation (with space:create_index operation).

As for index construction during recovery (a lack of function
cache during recovery was the main motivation to introduce
_func_index space), it's workflow is kept unchanged.

Follow up #1250
Needed for #4348
Closes #4401
@kyukhin kyukhin modified the milestones: 2.3.1, 2.4.1 Nov 21, 2019
@kyukhin kyukhin modified the milestones: 2.4.1, 2.5.1 Feb 12, 2020
olegrok added a commit that referenced this issue Mar 31, 2020
After #4083 (Implement transnational DDL for single-yield stmt
sets) we could make all box.schema functions transactional.

For that this patch implements special wrapper that open and close
transaction for some function if there is no active transactions.

Closes #4348
olegrok added a commit that referenced this issue Mar 31, 2020
After #4083 (Implement transnational DDL for single-yield stmt
sets) we could make all box.schema functions transactional.

For that this patch implements special wrapper that open and close
transaction for some function if there is no active transactions.
However some operations as index build, format changing could be
transactional only for empty spaces. This cases are handled
separately.

Closes #4348
@kyukhin kyukhin modified the milestones: 2.5.1, 2.6.1 Apr 23, 2020
@kyukhin kyukhin modified the milestones: 2.6.1, wishlist Oct 23, 2020
@kyukhin kyukhin added tmp teamC and removed tmp labels Jul 14, 2021
@TarantoolBot TarantoolBot removed the teamC label Jun 7, 2023
mkostoevr added a commit that referenced this issue Jun 8, 2023
mkostoevr added a commit that referenced this issue Jun 8, 2023
mkostoevr added a commit that referenced this issue Jun 9, 2023
Few years ago transactional DDL was implemented so now it's
possible to perform DDL operations atomically by wrapping them
into transactions.

Closes #4348

NO_DOC=bugfix
alyapunov added a commit to alyapunov/tarantool that referenced this issue Aug 7, 2023
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 added a commit to alyapunov/tarantool that referenced this issue Aug 7, 2023
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 added a commit that referenced this issue Aug 7, 2023
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)
alyapunov added a commit that referenced this issue Aug 7, 2023
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)
mkostoevr added a commit that referenced this issue Aug 22, 2023
Wraps DDL functions into begin/commit block if no transaction is
active.

Closes #4348

NO_DOC=bugfix
mkostoevr added a commit that referenced this issue Aug 22, 2023
Wraps DDL functions into begin/commit block if no transaction is
active.

Closes #4348

NO_DOC=bugfix
mkostoevr added a commit that referenced this issue Aug 22, 2023
Wraps DDL functions into begin/commit block if no transaction is
active.

Closes #4348

NO_DOC=bugfix
mkostoevr added a commit that referenced this issue Aug 22, 2023
Wraps DDL functions into begin/commit block if no transaction is
active.

Closes #4348

NO_DOC=bugfix
mkostoevr added a commit to mkostoevr/tarantool that referenced this issue Sep 7, 2023
Wraps DDL functions into begin/commit block if no transaction is
active.

Closes tarantool#4348

NO_DOC=bugfix
mkostoevr added a commit to mkostoevr/tarantool that referenced this issue Sep 8, 2023
Wraps DDL functions into begin/commit block if no transaction is
active.

Closes tarantool#4348

NO_DOC=bugfix
mkostoevr added a commit that referenced this issue Sep 9, 2023
Wraps DDL functions into begin/commit block if no transaction is
active.

Closes #4348

NO_DOC=bugfix
mkostoevr added a commit that referenced this issue Sep 10, 2023
Wraps multistatement DDL functions into begin/commit block if no
transaction is active.

The functions are:
- `box.schema.space.drop`
- `box.schema.index.create`
- `box.schema.index.drop`
- `box.schema.sequence.drop`
- `box.schema.func.drop`
- `box.schema.user.create`
- `box.schema.user.drop`
- `box.schema.role.drop`

TBD: Make `box.schema.index.alter` atomic.

Closes #4348

NO_DOC=bugfix
mkostoevr added a commit that referenced this issue Sep 10, 2023
Wraps multistatement DDL functions into begin/commit block if no
transaction is active.

The functions are:
- `box.schema.space.drop`
- `box.schema.index.create`
- `box.schema.index.drop`
- `box.schema.sequence.drop`
- `box.schema.func.drop`
- `box.schema.user.create`
- `box.schema.user.drop`
- `box.schema.role.drop`

TBD: Make `box.schema.index.alter` atomic.

Closes #4348

NO_DOC=bugfix
mkostoevr added a commit that referenced this issue Sep 11, 2023
Wraps multistatement DDL functions into begin/commit block if no
transaction is active.

The functions are:
- `box.schema.space.drop`
- `box.schema.index.create`
- `box.schema.index.drop`
- `box.schema.sequence.drop`
- `box.schema.func.drop`
- `box.schema.user.create`
- `box.schema.user.drop`
- `box.schema.role.drop`

TBD: Make `box.schema.index.alter` atomic.

Closes #4348

NO_DOC=bugfix
mkostoevr added a commit that referenced this issue Sep 11, 2023
Wraps multistatement DDL functions into begin/commit block if no
transaction is active.

The functions are:
- `box.schema.space.drop`
- `box.schema.index.create`
- `box.schema.index.drop`
- `box.schema.sequence.drop`
- `box.schema.func.drop`
- `box.schema.user.create`
- `box.schema.user.drop`
- `box.schema.role.drop`

TBD: Make `box.schema.index.alter` atomic.

Closes #4348

NO_DOC=bugfix
mkostoevr added a commit that referenced this issue Sep 11, 2023
Wraps multistatement DDL functions into begin/commit block if no
transaction is active.

The functions are:
- `box.schema.space.drop`
- `box.schema.index.create`
- `box.schema.index.drop`
- `box.schema.sequence.drop`
- `box.schema.func.drop`
- `box.schema.user.create`
- `box.schema.user.drop`
- `box.schema.role.drop`

TBD: Make `box.schema.index.alter` atomic.

Closes #4348

NO_DOC=bugfix
mkostoevr added a commit that referenced this issue Sep 12, 2023
Wraps multistatement DDL functions into begin/commit block if no
transaction is active.

The functions are:
- `box.schema.space.drop`
- `box.schema.index.create`
- `box.schema.index.drop`
- `box.schema.sequence.drop`
- `box.schema.func.drop`
- `box.schema.user.create`
- `box.schema.user.drop`
- `box.schema.role.drop`

Added tests for atomicity of each transactioned function except
the `box.schema.role.drop`, which is implicitly tested with the
`box.schema.user.drop` test, and the `box.schema.index.drop`,
which is impossible to test in this flavor whthout using error
injection.

Updated the tests modified in #8947, because
the space drop is atomic now.

TBD: Make `box.schema.index.alter` atomic.

Closes #4348

NO_DOC=bugfix
mkostoevr added a commit that referenced this issue Sep 12, 2023
Wraps multistatement DDL functions into begin/commit block if no
transaction is active.

The functions are:
- `box.schema.space.drop`
- `box.schema.index.create`
- `box.schema.index.drop`
- `box.schema.sequence.drop`
- `box.schema.func.drop`
- `box.schema.user.create`
- `box.schema.user.drop`
- `box.schema.role.drop`

Added tests for atomicity of each transactioned function except
the `box.schema.role.drop`, which is implicitly tested with the
`box.schema.user.drop` test, and the `box.schema.index.drop`,
which is impossible to test in this flavor whthout using error
injection.

Updated the tests modified in #8947, because
the space drop is atomic now.

TBD: Make `box.schema.index.alter` atomic.

Closes #4348

NO_DOC=bugfix
mkostoevr added a commit that referenced this issue Sep 13, 2023
Wraps multistatement DDL functions into begin/commit block if no
transaction is active.

The functions are:
- `box.schema.space.drop`
- `box.schema.index.create`
- `box.schema.index.drop`
- `box.schema.index.alter`
- `box.schema.sequence.drop`
- `box.schema.func.drop`
- `box.schema.user.create`
- `box.schema.user.drop`
- `box.schema.role.drop`

Added tests for atomicity of each transactioned function except
the `box.schema.role.drop`, which is implicitly tested with the
`box.schema.user.drop` test, and the `box.schema.index.drop`,
which is impossible to test in this flavor whthout using error
injection.

Updated the tests modified in #8947, because
the space drop is atomic now.

Closes #4348

NO_DOC=bugfix
mkostoevr added a commit that referenced this issue Sep 13, 2023
Wraps multistatement DDL functions into begin/commit block if no
transaction is active.

The functions are:
- `box.schema.space.drop`
- `box.schema.index.create`
- `box.schema.index.drop`
- `box.schema.index.alter`
- `box.schema.sequence.drop`
- `box.schema.func.drop`
- `box.schema.user.create`
- `box.schema.user.drop`
- `box.schema.role.drop`

Added tests for atomicity of each transactioned function except
the `box.schema.role.drop`, which is implicitly tested with the
`box.schema.user.drop` test, and the `box.schema.index.drop`,
which is impossible to test in this flavor whthout using error
injection.

Updated the tests modified in #8947, because
the space drop is atomic now.

Closes #4348

NO_DOC=bugfix
mkostoevr added a commit that referenced this issue Sep 13, 2023
Wraps multistatement DDL functions into begin/commit block if no
transaction is active.

The functions are:
- `box.schema.space.drop`
- `box.schema.index.create`
- `box.schema.index.drop`
- `box.schema.index.alter`
- `box.schema.sequence.drop`
- `box.schema.func.drop`
- `box.schema.user.create`
- `box.schema.user.drop`
- `box.schema.role.drop`

Added tests for atomicity of each transactioned function except
the `box.schema.role.drop`, which is implicitly tested with the
`box.schema.user.drop` test, and the `box.schema.index.drop`,
which is impossible to test in this flavor whthout using error
injection.

Updated the tests modified in #8947, because
the space drop is atomic now.

Closes #4348

NO_DOC=bugfix
mkostoevr added a commit that referenced this issue Sep 14, 2023
Wraps multistatement DDL functions into begin/commit block if no
transaction is active.

The functions are:
- `box.schema.space.drop`
- `box.schema.index.create`
- `box.schema.index.drop`
- `box.schema.index.alter`
- `box.schema.sequence.drop`
- `box.schema.func.drop`
- `box.schema.user.create`
- `box.schema.user.drop`
- `box.schema.role.drop`

Added tests for atomicity of each transactioned function except
the `box.schema.role.drop`, which is implicitly tested with the
`box.schema.user.drop` test, and the `box.schema.index.drop`,
which is impossible to test in this flavor without using error
injection.

Updated the tests modified in #8947, because
the space drop is atomic now.

Closes #4348

NO_DOC=bugfix
mkostoevr added a commit that referenced this issue Sep 14, 2023
Wraps multistatement DDL functions into begin/commit block if no
transaction is active.

The functions are:
- `box.schema.space.drop`
- `box.schema.index.create`
- `box.schema.index.drop`
- `box.schema.index.alter`
- `box.schema.sequence.drop`
- `box.schema.func.drop`
- `box.schema.user.create`
- `box.schema.user.drop`
- `box.schema.role.drop`

Added tests for atomicity of each transactioned function except
the `box.schema.role.drop`, which is implicitly tested with the
`box.schema.user.drop` test, and the `box.schema.index.drop`,
which is impossible to test in this flavor without using error
injection.

Updated the tests modified in #8947, because
the space drop is atomic now.

Closes #4348

NO_DOC=bugfix
mkostoevr added a commit that referenced this issue Sep 14, 2023
Wraps multistatement DDL functions into begin/commit block if no
transaction is active.

The functions are:
- `box.schema.space.drop`
- `box.schema.index.create`
- `box.schema.index.drop`
- `box.schema.index.alter`
- `box.schema.sequence.drop`
- `box.schema.func.drop`
- `box.schema.user.create`
- `box.schema.user.drop`
- `box.schema.role.drop`

Added tests for atomicity of each transactioned function except
the `box.schema.role.drop`, which is implicitly tested with the
`box.schema.user.drop` test, and the `box.schema.index.drop`,
which is impossible to test in this flavor without using error
injection.

Updated the tests modified in #8947, because
the space drop is atomic now.

Closes #4348

NO_DOC=bugfix
@locker locker added the 3.0 Target is 3.0 and all newer release/master branches label Sep 14, 2023
locker pushed a commit that referenced this issue Sep 18, 2023
Wraps multistatement DDL functions into begin/commit block if no
transaction is active.

The functions are:
- `box.schema.space.drop`
- `box.schema.index.create`
- `box.schema.index.drop`
- `box.schema.index.alter`
- `box.schema.sequence.drop`
- `box.schema.func.drop`
- `box.schema.user.create`
- `box.schema.user.drop`
- `box.schema.role.drop`

Added tests for atomicity of each transactioned function except
the `box.schema.role.drop`, which is implicitly tested with the
`box.schema.user.drop` test, and the `box.schema.index.drop`,
which is impossible to test in this flavor without using error
injection.

Updated the tests modified in #8947, because
the space drop is atomic now.

Closes #4348

NO_DOC=bugfix
@kyukhin kyukhin removed this from the wishlist milestone Oct 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.0 Target is 3.0 and all newer release/master branches app ddl feature A new functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants