[MDEV-19670] MyRocks: key lookups into deleted data are very slow Created: 2019-06-01 Updated: 2023-04-27 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - RocksDB |
| Affects Version/s: | 10.2, 10.3, 10.4 |
| Fix Version/s: | 10.4 |
| Type: | Bug | Priority: | Major |
| Reporter: | Sergei Petrunia | Assignee: | Sergei Petrunia |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Description |
|
This is based on a report from a user. Steps to reproduce with a totally synthetic dataset:
The query (originally it was a join):
The query itself returns 100 rows in 0.01 sec. Now, let's do the same in the transaction:
Re-running the query:
The EXPLAIN is the same, but the query now takes 1.25 sec. |
| Comments |
| Comment by Sergei Petrunia [ 2019-06-01 ] | |||||||||||||||||||||||||||
|
Excerpt from perf report:
| |||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2019-06-01 ] | |||||||||||||||||||||||||||
|
Debugging manually, I see that it spends a lot of time reading tombstones from the WriteBatch. RocksDB actually has "Iterator bounds" optimization which allows to avoid enumerating a lot of tombstones. Apparently that optimization only applies to committed data. | |||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2019-06-01 ] | |||||||||||||||||||||||||||
|
The slowdown happens in BaseDeltaIterator::UpdateCurrent There, base_iterator_ reads committed data, delta_iterator_ reads uncommitted changes. When an index lookup is made, the following happens:
| |||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2019-06-01 ] | |||||||||||||||||||||||||||
|
A patch against RocksDB that fixes this: https://gist.github.com/spetrunia/919dd95b1943ab52a032f134af8951e4 | |||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2019-06-01 ] | |||||||||||||||||||||||||||
|
Draft pull request: https://github.com/facebook/rocksdb/pull/5403 | |||||||||||||||||||||||||||
| Comment by Julien Muchembled [ 2020-05-15 ] | |||||||||||||||||||||||||||
|
Between 10.4.12 & 10.4.13, rocksdb was upgraded (no release notes about it) and the fix for this bug seems to be included. Do you confirm? |