[MDEV-6878] Use of uninitialized saved_primary_key in Mrr_ordered_index_reader::resume_read() Created: 2014-10-16 Updated: 2014-10-28 Resolved: 2014-10-16 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.0.12 |
| Fix Version/s: | 10.0.15 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Jeremy Cole | Assignee: | Sergei Petrunia |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | ds-mrr, optimizer | ||
| Description |
|
I believe that Mrr_ordered_index_reader::resume_read() is using saved_primary_key uninitialized if the current read hasn't been interrupted. This manifests itself in our case with the following case:
Our query produces an EXPLAIN containing:
With the result of the query we get many warnings like:
This is because the buffer being purported to be column 'y' is uninitialized or random data, and doesn't pass as valid UTF-8. Unfortunately I don't have a minimal test case for this yet, but I am able to reproduce it with sensitive data locally and can prove that the below patch fixes the symptom. Patch follows:
|
| Comments |
| Comment by Sergei Petrunia [ 2014-10-16 ] | |||||||||||||||||||||||||||||||||||
|
I could create a small testcase:
| |||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2014-10-16 ] | |||||||||||||||||||||||||||||||||||
|
I'm a little concerned about checking have_saved_rowid. It is defined as
which I suspect is not exactly the same as "whether saved_key_tuple and saved_primary_key point to valid tuples that resume_read() should restore" | |||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2014-10-16 ] | |||||||||||||||||||||||||||||||||||
|
The patch is here: http://lists.askmonty.org/pipermail/commits/2014-October/006793.html @ jeremycole, could you test your case with this patch? | |||||||||||||||||||||||||||||||||||
| Comment by Jeremy Cole [ 2014-10-16 ] | |||||||||||||||||||||||||||||||||||
|
psergey: I was wondering about that. I thought about adding a new boolean was_interrupted but it seemed like (to my uninformed self) that have_saved_rowid was already for that purpose. It looks like your patch also corrects the symptom we were seeing with production data/query as well, so the patch looks fine to me. I am a bit concerned that none of this fairly important optimizer code (it would seem most of MRR) has any meaningful test coverage, such that even my potentially incorrect patch doesn't cause any tests to fail, and so that these bugs can exist up to now. | |||||||||||||||||||||||||||||||||||
| Comment by Jeremy Cole [ 2014-10-16 ] | |||||||||||||||||||||||||||||||||||
|
All tests pass here, with the new patch. | |||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2014-10-16 ] | |||||||||||||||||||||||||||||||||||
|
(didn't see the comments) | |||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2014-10-16 ] | |||||||||||||||||||||||||||||||||||
|
jeremycole, there was some RQG-based testing before (the interrupt_read()/resume_read() functions were added as fix for https://bugs.launchpad.net/maria/+bug/671340, before 5.3/5.5 was GA). MP AB's jira shows there was more RQG testing done after 5.3/5.5 GA, also. I agree with your argument that mtr tests do not have much coverage - to fully test code around interrupt/resume_read one needs to run out of buffer space and/or lookup keys at some particular points, etc. This makes it hard to test with MTR - one needs to run loads of similar queries. I've asked elenst to run RQG tests again on fix for this bug. |