[MDEV-21314] Range Locking: individual rows are locked when scanning PK Created: 2019-12-13 Updated: 2021-02-15 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - RocksDB |
| Affects Version/s: | N/A |
| Fix Version/s: | 10.2 |
| Type: | Bug | Priority: | Major |
| Reporter: | Sergei Petrunia | Assignee: | Sergei Petrunia |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
||||||||||||||||
| Issue Links: |
|
||||||||||||||||
| Description |
|
The output shows overlapping ranges because we're in STO-mode. |
| Comments |
| Comment by Sergei Petrunia [ 2019-12-13 ] | ||||||||||||
|
The statement
It is executed as scan on PK in [10..20].. and for each found row, MySQL calls GetForUpdate(). GetForUpdate acquires a point lock on the row it is reading. | ||||||||||||
| Comment by Sergei Petrunia [ 2019-12-13 ] | ||||||||||||
|
But it doesn't stop there. TransactionBaseImpl::Put will make this call:
With point locking, PessimisticTransaction::TryLock will reach this:
where it it will not try to re-acquire the lock. With Range Locking we'll get here instead:
and WILL acquire the lock another time. | ||||||||||||
| Comment by Sergei Petrunia [ 2019-12-13 ] | ||||||||||||
|
Re-running
| ||||||||||||
| Comment by Sergei Petrunia [ 2019-12-13 ] | ||||||||||||
|
This is a 30-40% speedup for high-concurrency workloads:
|