[MDEV-10649] Optimizer sometimes use "index" instead of "range" access for UPDATE where PK IN (small list of values) Created: 2016-08-23 Updated: 2016-09-28 Resolved: 2016-09-28 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB |
| Affects Version/s: | 10.1.14 |
| Fix Version/s: | 10.1.18, 10.0.28 |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Valerii Kravchuk | Assignee: | Sergei Petrunia |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | upstream | ||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Sprint: | 10.1.18 | ||||||||
| Description |
|
There is a big table in a statement-based parallel replication setup, like this:
Usually status is updated for several ids in a single UPDATE like this:
So, we have range access and reasonable estimation of rows in range. We may get this plan hundreds of times in a row, but sometimes we end up with a totally different plan while this same query is executed by slave:
Optimizer used full index scan for the PRIMARY key (and estimated rows as 1), and this caused a very slow execution of the query and millions of locks set in the process that stalled all other parallel replication threads eventually in a "deadlock". I suspect there is a bug/corner case somewhere in the optimizer when it decides about indexes available for range access. Maybe this is caused by bad InnoDB statistics etc, but in any case I think we should prevent such an execution path. |
| Comments |
| Comment by Sergei Petrunia [ 2016-09-06 ] |
|
Attached files
mdev10649.test
|
| Comment by Sergei Petrunia [ 2016-09-06 ] |
|
http://lists.askmonty.org/pipermail/commits/2016-September/009777.html (has a small bug, see the patch attached below) |
| Comment by Sergei Petrunia [ 2016-09-12 ] |
|
The issue is also repeatable on MySQL 5.7.15. |
| Comment by Sergei Petrunia [ 2016-09-12 ] |
|
The adjusted the patch after Monty's review : mdev10649-r2.diff |