[MDEV-19361] Assertion `marked_for_read()' failed in Field_long::val_int Created: 2019-04-29 Updated: 2021-10-13 Resolved: 2021-10-13 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Views, Virtual Columns |
| Affects Version/s: | 10.4, 10.5 |
| Fix Version/s: | 10.4.11 |
| Type: | Bug | Priority: | Major |
| Reporter: | Elena Stepanova | Assignee: | Unassigned |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||||||
| Description |
|
No obvious failure on a non-debug build. Not reproducible on 10.3. |
| Comments |
| Comment by Elena Stepanova [ 2019-08-05 ] | ||||||||||||||||||||||||||||||||
|
I have removed the InnoDB variation of the test case, as it turned out it had nothing to do with this bug (or virtual columns in general). It was added to | ||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2019-09-11 ] | ||||||||||||||||||||||||||||||||
|
Here is a much simpler test case which produces the same assertion failure with all of MyISAM, Aria, InnoDB.
| ||||||||||||||||||||||||||||||||
| Comment by Alice Sherepa [ 2020-09-04 ] | ||||||||||||||||||||||||||||||||
|
The test from description currently does not fail (10.5 48ab5a4997b073f, 10.4 571764c04fc9b736366 ), but the test from the above comment fails on 10.4, 10.5 | ||||||||||||||||||||||||||||||||
| Comment by Nikita Malyavin [ 2021-06-28 ] | ||||||||||||||||||||||||||||||||
|
The latter test case (with DELETE LIMIT 1) duplicates | ||||||||||||||||||||||||||||||||
| Comment by Nikita Malyavin [ 2021-06-29 ] | ||||||||||||||||||||||||||||||||
|
The reason the initial test case does not fail is optimizer behavior change present by
Reverting this code hunk makes the issue reproducible | ||||||||||||||||||||||||||||||||
| Comment by Nikita Malyavin [ 2021-06-29 ] | ||||||||||||||||||||||||||||||||
|
Night is spent on trying to expose the fact that table->prepare_for_keyread sets the bits for a virtual field, if it was used, but not for the fields inside the vcol expression. In JOIN::init_join_caches():
tab->read_first_record can be join_read_first when the key is a covering key, i.e. includes all the fields involved in select.
is the only place which seems to be possibly reachable. However, covering_keys are intersected with hinting keys. Using asterisk (SELECT *) is pointless, since it will then load the record anyway, and mark a read bit. Using USE/FORCE INDEX [FOR ORDER BY] did not provide any success. test_if_skip_sort_order is left unreachable even under ~50k rows test. | ||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2021-06-29 ] | ||||||||||||||||||||||||||||||||
I don't understand the point you make by closing it as "Can't reproduce" based on the above. | ||||||||||||||||||||||||||||||||
| Comment by Nikita Malyavin [ 2021-06-29 ] | ||||||||||||||||||||||||||||||||
|
So the index was chosen correctly:
Keyread is enabled. However, we can see from the description stack trace that rr_sequential was used, which is incorrect due to keyread. First, in best_access_path rowid filter was assigned:
This is what was changed by the patch.
Then it was disabled, also there
info->read_record_func= rr_sequential; {cpp}is evaluated psergei can you tell if there are other ways to create rowid filter together with keyread enabled? My point is this combination exposes the bug. After 4d4b2867a fix mentioned above, the latter code path is no longer accessible since && (found_part & 1) is added which means there should be a primary key. But then b will be in ext key parts and will be marked for read. (However I guess, rr_sequential will still be chosen, and keyread can be wrongly finished) So we can't at least add PK to the table. It is better to leave the test case as is. I wonder if the issue can be reproduced with carefully configured optimizer switch | ||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2021-10-13 ] | ||||||||||||||||||||||||||||||||
|
The original test case in the description required rowid_filter, and that failure disappeared after this commit (released in 10.4.11):
And the alternative test case in the comments was fixed by |