[MDEV-18227] MyRocks-Gap-Lock: Lock escalation and updates to transaction's list of owned locks Created: 2019-01-14 Updated: 2019-01-15 Resolved: 2019-01-15 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - RocksDB |
| Fix Version/s: | N/A |
| Type: | Task | Priority: | Major |
| Reporter: | Sergei Petrunia | Assignee: | Sergei Petrunia |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
In TokuDB/PerconaFT range locking works as follows:
It is defined as follows:
Lock escalation joins multiple locks into one in the global lock tree. Then it calls escalation callback (which points to toku_db_txn_escalate_callback()).
The 3rd parameter of the function is a list of ranges that the transaction has locked after the escalation. toku_db_txn_escalate_callback replaces transaction's list of owned ranges with the provided list. One thing to care about is that lock escalation can happen in thread X, while the transaction operates in thread Y. So, access to db_txn_struct_i(txn)->lt_map (or its equivalent) must be synchronized. |
| Comments |
| Comment by Sergei Petrunia [ 2019-01-14 ] | ||||||||||||||||||||||||||||||||||||||||||||
|
...and in TokuDB it is not fully synchronized. Consider this example: apply this patch: Start the server.
Thread 2: insert something to disable STO:
Thread 1: acquire 10 locks:
Start acquiring 11th lock. Freeze the execution after we've got the lock, but before db_txn_note_row_lock has added it into the transaction's list of owned locks.
Thread 2:
b toku::locktree_manager::check_current_lock_constraints.
return true from check_current_lock_constraints, observe this in debugger:
Continue and let Thread2's insert to complete.
and see how this call
will add a lock on point "12"
into the post-escalation lock list:
So, this property exists, but is currently harmless. |