[MDEV-7122] Assertion `0' failed in subselect_hash_sj_engine::init Created: 2014-11-17 Updated: 2016-02-10 Resolved: 2016-02-10 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 5.5, 10.0 |
| Fix Version/s: | 5.5.48 |
| Type: | Bug | Priority: | Major |
| Reporter: | Elena Stepanova | Assignee: | Vicențiu Ciorbaru |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | upstream-fixed | ||
| Sprint: | 5.5.47-1, 5.5.48-0 |
| Description |
|
The bug report was initially reported upstream as http://bugs.mysql.com/bug.php?id=74889. On MariaDB 5.5/10.0, the same test case causes a different assertion failure. Even if it's related, the upstream issue is said to be fixed in 5.6.22 (it's not public yet, so couldn't check), and since it's not InnoDB, the bugfix won't be automatically merged to 10.0.
|
| Comments |
| Comment by Daniel Black [ 2015-10-23 ] | ||||||||||||||||||||||||||||||||||
|
I had a look and couldn't see anything buts its probably here somewhere https://github.com/mysql/mysql-server/compare/mysql-5.5.21...mysql-5.5.22 | ||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2015-12-09 ] | ||||||||||||||||||||||||||||||||||
|
So, it is trying to initialize the query plan for non-merged semi-join materialization strategy (aka JTBM=Join TaB Materialization). And the assert is here:
That is, we assert when we have created a temporary table, but it turned out that the table has no keys (=> and hence it is not suitable for doing Materialization, without keys one can't remove duplicates or make efficient lookups). | ||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2015-12-09 ] | ||||||||||||||||||||||||||||||||||
|
Note that without SET SESSION big_tables=1 the query works, and its EXPLAIN is:
| ||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2015-12-09 ] | ||||||||||||||||||||||||||||||||||
|
Debugging create_tmp_table(). without big_tables=1
with big_tables=1:
table->file is a ha_maria object. The execution proceeds in the same way as in the working case, until we reach
create_internal_tmp_table() is only called when table->file is ha_maria object.
The outermost if is taken, the innermost is not. We can see: it is unable to create a key and falls back to using a "constraint" instead. | ||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2015-12-09 ] | ||||||||||||||||||||||||||||||||||
|
The reason it is unable to create a key:
| ||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2015-12-09 ] | ||||||||||||||||||||||||||||||||||
|
This is a long-known problem:
| ||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2015-12-09 ] | ||||||||||||||||||||||||||||||||||
|
Searching through OPTIMIZER_SWITCH_MATERIALIZATION finds the function that
| ||||||||||||||||||||||||||||||||||
| Comment by Vicențiu Ciorbaru [ 2016-02-08 ] | ||||||||||||||||||||||||||||||||||
|
Hi Sergei, Can you please review the patch for this bug? The patch is on the commits mailing list: http://lists.askmonty.org/pipermail/commits/2016-February/008975.html Regards, | ||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2016-02-09 ] | ||||||||||||||||||||||||||||||||||
|
Checking limits in storage engines:
| ||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2016-02-09 ] | ||||||||||||||||||||||||||||||||||
|
Looking at the above:
Discussed the issue with serg. Conclusions:
for MAX_KEY_LENGTH, we need to #define MAX_TMP_TABLE_KEY_LENGTH, and then
cvicentiu any objections? If not pelase implement this. | ||||||||||||||||||||||||||||||||||
| Comment by Vicențiu Ciorbaru [ 2016-02-10 ] | ||||||||||||||||||||||||||||||||||
|
Due to differences in storage engines, we ended up implementing an #ifdef'ed solution. Based on the temporary table storage engine, a new function called tmp_table_max_key_ {length|parts}() returns the required values. | ||||||||||||||||||||||||||||||||||
| Comment by Vicențiu Ciorbaru [ 2016-02-10 ] | ||||||||||||||||||||||||||||||||||
|
Fixed with: |