-
Notifications
You must be signed in to change notification settings - Fork 377
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
memtx: make user changes transactional
There are a few issues concerning TX manager and DDL operations. The thing is metadata stored for any object is not currently designed to be versioned. It means that several transactions can see changes provided by each other BEFORE they are committed. Which is considered to be a disaster and violates all transaction processing principles (speaking of serializable isolation level). Regarding users in particular, there's quite simple test case leading to the crash. Imagine two transaction creating a user with the same ID at the same moment: tx1:begin() tx2:begin() tx1("box.schema.user.create('internal1')") tx2("box.schema.user.create('internal2')") First operation creates and adds user with ID_1 to user cache; second operation finds user by the same ID_1 and attempts to update it (to be more precise - its name). We get the same ID since ID for user is generated based on the last value appearing in the space; before transaction is committed the last value for both transactions is the same. In on_replace_dd_user() trigger we assume that the operation is update/replace if we find user in the cache by its id (in contrast to other on_replace DDL triggers where we look at presence of old_tuple). Unfortunately on_rollback trigger supposes that old_tuple is not null. Meanwhile it is: until first TX commits its changes, old_tuple does not exist. In scope of this patch we are going to fix several problems at once. Firstly, let's add to the struct user id of the transaction that attempts at modifying it. It is assigned after change in on_replace_dd_user() and reset to zero in on_commit/on_rollback triggers. If any other transaction (with different id) wants to acquire the same user - we raise an error saying that user is already busy. To deal with the situation when TX deletes user, we also add is_deleted flag which indicates that user has been deleted but transaction is still not committed. Secondly, let's rework on_rollback and introduce on_commit triggers of on_replace_dd_user(). Now they accept struct user or user_def and reset tx id of user. Obviously, that patch doesn't fix all the problems. In fact, users have quite sophisticated implementation. They are stored in two places: as an static array and in cache. Furthermore, we maintain dependency graph for roles and RB-Tree of privileges for each user. That makes tracking of privilege updates complicated. So that we don't touch this part in scope of current patch. Part of #6138 Closes #5998
- Loading branch information
1 parent
72fc94e
commit 2c5e81a
Showing
7 changed files
with
824 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.