[MDEV-4822] Wrong result (missing row) with index scan over Aria table Created: 2013-07-28 Updated: 2014-01-26 Resolved: 2014-01-26 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | 10.0.3, 5.5.32 |
| Fix Version/s: | 5.5.35 |
| Type: | Bug | Priority: | Major |
| Reporter: | Elena Stepanova | Assignee: | Michael Widenius |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | optimizer | ||
| Issue Links: |
|
||||
| Description |
|
Note: It looks like other bugs we had with index_merge, but I don't remember (and can't find) a combination with Aria, so I'll file it in case it's different.
Actual result:
Expected result:
bzr version-info
Also reproducible on 10.0 and 10.0-base, but not on 5.3. Minimal optimizer_switch: index_merge=on,index_merge_sort_union=on EXPLAIN:
|
| Comments |
| Comment by Sergei Petrunia [ 2013-08-23 ] | ||||||||||||||||||||
|
It is possible to construct a testcase that is not using index_merge: MariaDB [j4]> CREATE TABLE t1 (id INT, state VARCHAR(10), INDEX(state), PRIMARY KEY (id)) ENGINE=Aria; MariaDB [j4]> ALTER TABLE t1 DISABLE KEYS; MariaDB [j4]> INSERT INTO t1 VALUES (1,'California'),(2,'Ohio'); MariaDB [j4]> INSERT INTO t1 VALUES (3,'Alabama'),(4,'Jersey'); MariaDB [j4]> ALTER TABLE t1 ENABLE KEYS; MariaDB [j4]> SELECT * FROM t1 FORCE KEY (PRIMARY) WHERE id < 255;
---
--- MariaDB [j4]> SELECT * FROM t1 IGNORE KEY (PRIMARY) WHERE id < 255;
---
--- | ||||||||||||||||||||
| Comment by Sergei Petrunia [ 2013-08-23 ] | ||||||||||||||||||||
|
EXPLAIN for the problematic query: MariaDB [j4]> explain SELECT * FROM t1 FORCE KEY (PRIMARY) WHERE id < 255;
-----
----- | ||||||||||||||||||||
| Comment by Sergei Petrunia [ 2013-08-23 ] | ||||||||||||||||||||
|
EXPLAIN shows that Index Condition Pushdown is used. If I disable it and run this testcase: set optimizer_switch='index_condition_pushdown=off'; I still see the same difference. The EXPLAIN w/o ICP is: MariaDB [j4]> explain SELECT * FROM t1 FORCE KEY (PRIMARY) WHERE id < 255;
-----
----- | ||||||||||||||||||||
| Comment by Sergei Petrunia [ 2013-08-23 ] | ||||||||||||||||||||
|
The issue is not always repeatable. For example, for the above testcase:
| ||||||||||||||||||||
| Comment by Sergei Petrunia [ 2013-08-23 ] | ||||||||||||||||||||
|
I have ran the SELECT ... FORCE KEY (PRIMARY) ... query side-by side, correct and incorrect execution. The difference comes from inside Aria engine. The execution proceeds as follows: ha_maria::index_first() = 0 // returns id=1, state=California | ||||||||||||||||||||
| Comment by Sergei Petrunia [ 2013-08-23 ] | ||||||||||||||||||||
|
The difference in execution happens here: here we are in trnman_can_read_from() at: if (trid >= trn->trid) { /* We have now two cases trid > trn->trid, in which case the row is from a new transaction and not visible, in which case we should return 0. trid == trn->trid in which case the row is from the current transaction and we should return 1 */ => return trid == trn->trid; }and we have (gdb) print trid (gdb) fini ... and from here we go to call _ma_search_next(), which continues until the end of the table and then returns HA_ERR_END_OF_FILE. | ||||||||||||||||||||
| Comment by Sergei Petrunia [ 2013-08-23 ] | ||||||||||||||||||||
|
Considering the above, this is Aria storage engine issue. | ||||||||||||||||||||
| Comment by Michael Widenius [ 2014-01-26 ] | ||||||||||||||||||||
|
This was the same bug as in |