[MDEV-11846] ERROR 1114 (HY000) table full when performing GROUP BY Created: 2017-01-19 Updated: 2017-09-24 Resolved: 2017-09-24 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - MyISAM |
| Affects Version/s: | 10.1.17, 10.0.27, 5.5, 10.0, 10.1, 10.2 |
| Fix Version/s: | 10.1.27 |
| Type: | Bug | Priority: | Major |
| Reporter: | Philip | Assignee: | Varun Gupta (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
GNU/Linux |
||
| Sprint: | 10.2.6-3, 10.3.1-1 |
| Description |
|
GROUP BY queries from MyISAM tables consistently fails with 'TABLE FULL' for some lengths of fields being grouped but succeeds for longer lengths. Does not appear to be hitting operating system limits. For example, with a source MyISAM table 'test.input' of 10m records defined as field a=int(11) auto-increment primary key (values 1-10,000,000) and field b defined as varchar(128) not null and randomly filled, then the following fail but any other length (1-127) runs OK:
Replacing the length with @len causes the crash to occur with values of @len that are 1 lower than the lengths above: i.e. @len=61, 62, 79 and 80. While the query is running, a pair of files (.MAI, .MAD) are being created in /tmp; the query crashes at the point that the .MAI file is about the exceed 512Mb. For other lengths the .MAI file exceeds 512Mb without crashing. /tmp has over 404Gb free space available. None of the conditions documented at http://dev.mysql.com/doc/refman/5.5/en/table-size-limit.html apply in this case - plenty of disk space, query runs OK with longer values being grouped, not using InnoDB, file size is suitable for pointer size, etc. The solution listed elsewhere for specifying MAX_ROWS is for when explicitly creating an Aria table; MariaDB is implicitly creating the table so cannot specify MAX_ROWS. In any cases, 10m rows is not excessive. Table input:
Table input created and populated as:
Selected settings:
|
| Comments |
| Comment by Elena Stepanova [ 2017-02-24 ] | ||||||||||||||||||||||||||||||||||||
|
Thanks for the report and test case. CREATE TABLE .. AS is not necessary, a subquery does the same.
| ||||||||||||||||||||||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2017-03-31 ] | ||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2017-04-06 ] | ||||||||||||||||||||||||||||||||||||
|
When it gets the error, which table is it writing to? Is it
| ||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2017-04-06 ] | ||||||||||||||||||||||||||||||||||||
|
For the table that it has an error with, | ||||||||||||||||||||||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2017-05-23 ] | ||||||||||||||||||||||||||||||||||||
|
When we get the error we are actually writing to the temporary table for doing GROUP BY
| ||||||||||||||||||||||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2017-05-23 ] | ||||||||||||||||||||||||||||||||||||
|
For the derived table ss
For the work table that is when we do the group by
| ||||||||||||||||||||||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2017-06-01 ] | ||||||||||||||||||||||||||||||||||||
|
(lldb) p share->base.margin_key_file_length (lldb) p share->state.state.key_file_length
In the function maria_write, this is the place we get the error condition , that the index file is full | ||||||||||||||||||||||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2017-06-03 ] | ||||||||||||||||||||||||||||||||||||
|
After further investigation I see there is an overflow
| ||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2017-06-28 ] | ||||||||||||||||||||||||||||||||||||
|
So I am trying to reproduce the overrun. I can easily reproduce this part:
I get there and I see:
Oh, about to overrun...
Yes, here it is. | ||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2017-06-28 ] | ||||||||||||||||||||||||||||||||||||
|
But I'm not able to reproduce the overrun that the first portion of the patch is supposed to fix. Code before the patch:
Debugging:
So, we first divide max_rows by 44 and then multiply by 8192. This is (approximately) about the same as multiplying it by:
Trying to do this multiplication manually:
No overrun.
or, depending on which of the queries I try*
Can't observe the overrun for either of them. varun, please advice how to reproduce the overrun that the first portion of the patch is fixing. | ||||||||||||||||||||||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2017-06-28 ] | ||||||||||||||||||||||||||||||||||||
|
RIGHT(b,82), where you would be seeing the overflow for the other part of the patch. | ||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2017-06-29 ] | ||||||||||||||||||||||||||||||||||||
|
varun, I am debugging the query with RIGHT(b, 28) and I still don't see any overruns:
So it's like multipling max_rows by:
Stepping through, I get:
Please point out where exactly you see the overrun. | ||||||||||||||||||||||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2017-06-30 ] | ||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2017-06-30 ] | ||||||||||||||||||||||||||||||||||||
|
Ok, thanks! Actually, what I've posted above also shows the overflow, but I've missed it. I agree with what the patch does. There is one detail missing:
What if tot_length < ULLONG_MAX, and tot_length_part * maria_block_size < ULLONG_MAX , but when one adds them, there is an overflow? Please add handling for this case too. Hopefully this was the last comment on the patch. | ||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2017-09-21 ] | ||||||||||||||||||||||||||||||||||||
|
Ok to push |