[MDEV-3747] LP:724275 - Crash in JOIN::optimize in maria-5.3 Created: 2011-02-24 Updated: 2015-02-02 Resolved: 2012-10-04 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | ||
| Reporter: | Philip Stoev (Inactive) | Assignee: | Sergei Petrunia |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | Launchpad | ||
| Attachments: |
|
| Description |
|
Not repeatable in maria-5.3 Backtrace: #4 <signal handler called> bzr version-info: revision-id: <email address hidden> explain: id select_type table type possible_keys key key_len ref rows Extra test case: CREATE TABLE t1 ( f2 int(11), f3 int(11)) ; CREATE TABLE t2 ( f3 int(11)) ; CREATE TABLE t3 ( f1 int(11), f2 int(11), f3 int(11)) ; SELECT f2 FROM t3 |
| Comments |
| Comment by Philip Stoev (Inactive) [ 2011-02-25 ] | ||||||||||||||||||||||||||||||||||||||||||
|
Re: Crash in JOIN::optimize in maria-5.3-mwl90 Unfortunately, it was not possible to extract an MTR test case. So, in order to repeat, mount the attached datadir and execute; SELECT n_nationkey FROM nation JOIN supplier JOIN partsupp ON s_suppkey = ps_suppkey JOIN lineitem ON ps_partkey = l_partkey AND ps_suppkey = l_suppkey JOIN orders JOIN customer ON o_custkey = c_custkey WHERE ps_partkey = 199; If the datadir is dumped and loaded fresh, the query stops crashing and starts reporting "Impossible where", which is due to ps_partkey not having a value of 199. | ||||||||||||||||||||||||||||||||||||||||||
| Comment by Philip Stoev (Inactive) [ 2011-02-25 ] | ||||||||||||||||||||||||||||||||||||||||||
|
The same crash was observed with maria-5.3 and maria-5.3-mwl128, but with a vastly different data set and query. Unfortunately, it was not possible to extract an MTR test case. So, in order to repeat, mount the attached datadir and execute; SELECT n_nationkey FROM nation JOIN supplier JOIN partsupp ON s_suppkey = ps_suppkey JOIN lineitem ON ps_partkey = l_partkey AND ps_suppkey = l_suppkey JOIN orders JOIN customer ON o_custkey = c_custkey WHERE ps_partkey = 199; If the datadir is dumped and loaded fresh, the query stops crashing and starts reporting "Impossible where", which is due to ps_partkey not having a value of 199. datadir | ||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2011-02-28 ] | ||||||||||||||||||||||||||||||||||||||||||
|
Re: Crash in JOIN::optimize in maria-5.3 explain SELECT n_nationkey FROM nation JOIN supplier JOIN partsupp ON s_suppkey = ps_suppkey JOIN lineitem ON ps_partkey = l_partkey AND ps_suppkey = l_suppkey JOIN orders JOIN customer ON o_custkey = c_custkey WHERE ps_partkey = 199;
| ||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2011-02-28 ] | ||||||||||||||||||||||||||||||||||||||||||
|
Re: Crash in JOIN::optimize in maria-5.3 The crash happens when processing ref access on the `partsupp` table. The EXPLAIN shows:
i.e. partsupp uses ref acess over 2 key parts, with references being: const, test.lineitem.l_suppkey Now, if we look inside create_ref_for_key() function, we see this code: for (i=0 ; i < keyparts ; keyuse+,i+) else ref_key here points to tab->ref.key_copy, and it's easy to see that
If we then proceed to equality substitution code in JOIN::optimize(): /* Item **ref_item_ptr= tab->ref.items+i; } we'll see that the line marked with => assumes that tab->ref.key_copy[i] will hold an element for the i-th keypart. As was shown above, this is not true when we've had a reference to constant for some keypart N<i. As a result, we get the crash | ||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2011-02-28 ] | ||||||||||||||||||||||||||||||||||||||||||
|
Re: Crash in JOIN::optimize in maria-5.3 create table t1 (a int); create table t2 (a int, b int, key(a,b)); create table t0 (a int, b int, key(a)); select * from t0 straight_join t1 straight_join t2 force index(a) where t2.a=1 and t2.b=t1.a and t1.a=t0.b and t0.a=1; Program received signal SIGSEGV, Segmentation fault. | ||||||||||||||||||||||||||||||||||||||||||
| Comment by Rasmus Johansson (Inactive) [ 2011-12-13 ] | ||||||||||||||||||||||||||||||||||||||||||
|
Launchpad bug id: 724275 |