[MDEV-19873] Different EXPLAIN SELECT DISTINCT on just created table and after deleted records Created: 2019-06-26 Updated: 2023-04-27 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Optimizer, Storage Engine - InnoDB, Tests |
| Affects Version/s: | 5.5, 10.1, 10.2, 10.3, 10.4, 10.5 |
| Fix Version/s: | 10.4 |
| Type: | Bug | Priority: | Major |
| Reporter: | Aleksey Midenkov | Assignee: | Vladislav Lesin |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
Reproduce
ResultResults from first and second explain do not match:
ExpectedResults from first and second explain should be equal. Side-effectTest innodb.innodb_mysql is unstable, with --repeat=100 it fails:
InfoThe original fix was https://lists.mysql.com/commits/19658 but now result is overridden by 0700cde7f1071fb676d21794aaf97bf0a74acc61. |
| Comments |
| Comment by Marko Mäkelä [ 2019-06-27 ] | |||||||||||||||||||||||||||
|
My guess is that this happens because ha_innobase::records_in_range() is not only nondeterministic, but sometimes intentionally returning bogus values when it detects that the index tree was modified while the code was executing without holding appropriate page latches. Also, the function is probably not taking MVCC into account and could thus include purgeable (non-existing) records in the count. Both these problems might be infeasible to fix, because records_in_range() is expected to be fast. If it locked the appropriate upper level pages of the index tree, it might reduce concurrency too much. Likewise, taking MVCC into account especially in secondary indexes would be very costly (unless we implement MDEV-17598). Last but not least, I suspect that the optimizer can be unnecessarily invoking ha_innobase::records_in_range() multiple times. I remember one innodb_zip test essentially giving multiple different row counts for the same table, in different lines of the same EXPLAIN output. | |||||||||||||||||||||||||||
| Comment by Aleksey Midenkov [ 2019-06-27 ] | |||||||||||||||||||||||||||
|
A some measure should be done quickly that will at least fix unstable `innodb.innodb_mysql`. | |||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2019-06-28 ] | |||||||||||||||||||||||||||
|
The only feasible option that I see is to just remove the EXPLAIN from the test file. Just run the SELECT itself. (It might or might not use LooseScan. If it doesn't, we 've lost test coverage for this very old bugfix. Maintaining testcase coverage for bugfixes from >10 years ago doesn't seem like something worth spending time on ) (EITS statistics won't help here, because records_in_range estimates are only available from the storage engine. They cannot be replaced by range.) | |||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2019-06-28 ] | |||||||||||||||||||||||||||
|
(just trying something, give me a bit of time) | |||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2019-06-28 ] | |||||||||||||||||||||||||||
|
we can't use EITS to override records_in_range return value, but at least we can use it to override #rows_in_table and rec_per_key values.
The testcase doesn't fail for me anymore. midenok, can you try it? |