[MDEV-11162] Assertion `num_records == m_idx_array.size()' failed in Filesort_buffer::alloc_sort_buffer(uint, uint) Created: 2016-10-27 Updated: 2016-12-07 Resolved: 2016-12-07 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.0, 10.1 |
| Fix Version/s: | 10.0.29 |
| Type: | Bug | Priority: | Major |
| Reporter: | Elena Stepanova | Assignee: | Varun Gupta (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Reproducible on 10.0, 10.1. |
| Comments |
| Comment by Sergei Petrunia [ 2016-12-05 ] | |||||||||||||||||||||||||||||||||||||||||||||
|
Notes from our discussion with varun:
and the number 1129 doesn't make any sense. It looks like the code is using some garbage value left over from the previous query. | |||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2016-12-05 ] | |||||||||||||||||||||||||||||||||||||||||||||
|
Indeed, the value 1129 gets assigned by the previous query here in filesort():
[ | |||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2016-12-05 ] | |||||||||||||||||||||||||||||||||||||||||||||
|
It's not only the buffer length. The buffer itself is left, too:
and add a watchpoints to see where memory is allocated, I get:
then I see the buffer to be allocated
but it's never freed (checked by looking into .trace file. my_malloc with this address is there, my_free is not) | |||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2016-12-05 ] | |||||||||||||||||||||||||||||||||||||||||||||
|
Looking at where Filesort_buffer::free_sort_buffer() calls are made:
Need to check JOIN::cleanup() calls. | |||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2016-12-05 ] | |||||||||||||||||||||||||||||||||||||||||||||
|
Debugging when/how JOIN::cleanup is run for the query:
Look at frames #0, #1, #2, #3, #10.
| |||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2016-12-05 ] | |||||||||||||||||||||||||||||||||||||||||||||
|
Indeed, if I stop at the cleanup call for 0x7fffc7024390
I can follow it into the filesort_free_buffers(first_tab->table, full) call and see that the buffer that should have been freed is here:
| |||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2016-12-05 ] | |||||||||||||||||||||||||||||||||||||||||||||
|
The relationship between the two subquery's JOIN objects is that one of them points to another using tmp_join member:
I can see that
but then it immediately exits, without having called cleanup(1) for itself. | |||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2016-12-05 ] | |||||||||||||||||||||||||||||||||||||||||||||
|
This one seems to work (it's important to call cleanup() first, before destroy())
|