<?xml version="1.0" encoding="utf-8"?>
<launchpad-bug id="693329">
  <date_last_updated>2012-06-04 05:55:21.935678+00:00</date_last_updated>
  <api_links>
    <bug_api_link>https://api.launchpad.net/1.0/bugs/693329</bug_api_link>
    <bug_owner_link>https://api.launchpad.net/1.0/~philip-stoev</bug_owner_link>
    <milestone_link>https://api.launchpad.net/1.0/maria/+milestone/5.2</milestone_link>
    <linked_branches_collection_link>https://api.launchpad.net/1.0/bugs/693329/linked_branches</linked_branches_collection_link>
    <activity_link>https://api.launchpad.net/1.0/bugs/693329/activity</activity_link>
  </api_links>
  <bug_web_link>https://bugs.launchpad.net/bugs/693329</bug_web_link>
  <owner>Philip Stoev</owner>
  <assignee>Sergey Petrunia</assignee>
  <milestone_title>Maria 5.2</milestone_title>
  <duplicate_link></duplicate_link>
  <duplicate_bug_id></duplicate_bug_id>
  <title>Assertion `!is_interleave_error' failed on low optimizer_search_depth</title>
  <status>Confirmed</status>
  <importance>High</importance>
  <created>2010-12-22 10:26:49.690789+00:00</created>
  <description>
<![CDATA[As already reported in mysql bug http://bugs.mysql.com/bug.php?id=54429 , using low values for optimizer_search_depth causes an easy crash on multiple-table joins.

The RQG sometimes generates joins involving many tables. In order to restrict the total optimization time per query, and thus run more queries per test run, optimizer_search_depth must be safe to use and not assert.

assertion:
mysqld: sql_select.cc:5498: bool greedy_search(JOIN*, table_map, uint, uint): Assertion `!is_interleave_error' failed.

backtrace:

#8  0x006b0d98 in __assert_fail () from /lib/libc.so.6
#9  0x0831785c in greedy_search (join=0xae688eb0, remaining_tables=55, search_depth=4, prune_level=1) at sql_select.cc:5498
#10 0x08316ebc in choose_plan (join=0xae688eb0, join_tables=55) at sql_select.cc:5120
#11 0x0831205f in make_join_statistics (join=0xae688eb0, tables_arg=0xae631c80, conds=0x0, keyuse_array=0xae68dbec) at sql_select.cc:3216
#12 0x08309e93 in JOIN::optimize (this=0xae688eb0) at sql_select.cc:956
#13 0x0830fa81 in mysql_select (thd=0xb1fda70, rref_pointer_array=0xb1ff50c, tables=0xae631c80, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147764736, result=0xae64b8b0,
    unit=0xb1ff16c, select_lex=0xb1ff408) at sql_select.cc:2607
#14 0x0830800d in handle_select (thd=0xb1fda70, lex=0xb1ff110, result=0xae64b8b0, setup_tables_done_option=0) at sql_select.cc:286
#15 0x082a3400 in execute_sqlcom_select (thd=0xb1fda70, all_tables=0xae631c80) at sql_parse.cc:5070
#16 0x08299e1b in mysql_execute_command (thd=0xb1fda70) at sql_parse.cc:2234
#17 0x082a599e in mysql_parse (thd=0xb1fda70,
    rawbuf=0xae631940 "SELECT table2.f4  FROM t1  AS table1  LEFT  JOIN t1  AS table2  LEFT  JOIN t2  AS table3  LEFT  JOIN t3  AS table4  ON table3 .f1  = table4.f3  ON table2 .f1  LEFT  JOIN t4  AS table5  JOIN t5  ON tab"...,
    length=262, found_semicolon=0xae983228) at sql_parse.cc:6077
#18 0x08297904 in dispatch_command (command=COM_QUERY, thd=0xb1fda70,
    packet=0xb217c31 "SELECT table2.f4  FROM t1  AS table1  LEFT  JOIN t1  AS table2  LEFT  JOIN t2  AS table3  LEFT  JOIN t3  AS table4  ON table3 .f1  = table4.f3  ON table2 .f1  LEFT  JOIN t4  AS table5  JOIN t5  ON tab"...,
    packet_length=265) at sql_parse.cc:1210
#19 0x08296d6e in do_command (thd=0xb1fda70) at sql_parse.cc:903
#20 0x08293e4a in handle_one_connection (arg=0xb1fda70) at sql_connect.cc:1154
#21 0x00821919 in start_thread () from /lib/libpthread.so.0
#22 0x0076acce in clone () from /lib/libc.so.6

test case:

SET SESSION optimizer_search_depth = 4;

CREATE TABLE t1 (f1 int,f2 int,f3 int,f4 int) ;
INSERT IGNORE INTO t1 VALUES (0,0,2,0),(NULL,0,2,0);

CREATE TABLE t2 (f1 int) ;
CREATE TABLE t3 (f3 int,PRIMARY KEY (f3)) ;
CREATE TABLE t4 (f5 int) ;
CREATE TABLE t5 (f2 int) ;

SELECT alias2.f4  FROM t1  AS alias1
LEFT    JOIN t1  AS alias2
        LEFT  JOIN t2  AS alias3
        LEFT  JOIN t3  AS alias4  ON alias3.f1 = alias4.f3
        ON alias2.f1
LEFT    JOIN t4  AS alias5
        JOIN t5  ON alias5.f5
ON alias2.f3  ON alias1.f2   ;]]>  </description>
  <activities>
    <activity datechanged="2010-12-22T10:26:49.690789+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[]]>      </newvalue>
      <whatchanged>bug</whatchanged>
      <person>Philip Stoev</person>
      <message>added bug</message>
    </activity>
    <activity datechanged="2010-12-22T10:27:00.735955+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[Timour Katchaounov (timour)]]>      </newvalue>
      <whatchanged>maria: assignee</whatchanged>
      <person>Philip Stoev</person>
      <message></message>
    </activity>
    <activity datechanged="2010-12-22T10:27:02.393401+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[5.3]]>      </newvalue>
      <whatchanged>maria: milestone</whatchanged>
      <person>Philip Stoev</person>
      <message></message>
    </activity>
    <activity datechanged="2010-12-22T10:27:08.626361+00:00">
      <oldvalue>
<![CDATA[5.3]]>      </oldvalue>
      <newvalue>
<![CDATA[]]>      </newvalue>
      <whatchanged>maria: milestone</whatchanged>
      <person>Philip Stoev</person>
      <message></message>
    </activity>
    <activity datechanged="2010-12-22T10:32:32.285356+00:00">
      <oldvalue>
<![CDATA[Timour Katchaounov (timour)]]>      </oldvalue>
      <newvalue>
<![CDATA[Sergey Petrunia (sergefp)]]>      </newvalue>
      <whatchanged>maria: assignee</whatchanged>
      <person>Philip Stoev</person>
      <message></message>
    </activity>
    <activity datechanged="2011-04-06T12:48:52.714617+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[5.2]]>      </newvalue>
      <whatchanged>maria: milestone</whatchanged>
      <person>Philip Stoev</person>
      <message></message>
    </activity>
    <activity datechanged="2011-04-06T12:50:22.058869+00:00">
      <oldvalue>
<![CDATA[New]]>      </oldvalue>
      <newvalue>
<![CDATA[Confirmed]]>      </newvalue>
      <whatchanged>maria: status</whatchanged>
      <person>Philip Stoev</person>
      <message></message>
    </activity>
    <activity datechanged="2011-06-15T10:07:29.961821+00:00">
      <oldvalue>
<![CDATA[Undecided]]>      </oldvalue>
      <newvalue>
<![CDATA[High]]>      </newvalue>
      <whatchanged>maria: importance</whatchanged>
      <person>Sergey Petrunia</person>
      <message></message>
    </activity>
    <activity datechanged="2012-04-03T13:34:07.112586+00:00">
      <oldvalue>
<![CDATA[Confirmed]]>      </oldvalue>
      <newvalue>
<![CDATA[In Progress]]>      </newvalue>
      <whatchanged>maria: status</whatchanged>
      <person>Sergey Petrunia</person>
      <message></message>
    </activity>
    <activity datechanged="2012-04-03T15:35:18.210266+00:00">
      <oldvalue>
<![CDATA[In Progress]]>      </oldvalue>
      <newvalue>
<![CDATA[Confirmed]]>      </newvalue>
      <whatchanged>maria: status</whatchanged>
      <person>Sergey Petrunia</person>
      <message></message>
    </activity>
    <activity datechanged="2012-04-05T19:49:14.780590+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[assertion optimizer]]>      </newvalue>
      <whatchanged>tags</whatchanged>
      <person>Elena Stepanova</person>
      <message></message>
    </activity>
  </activities>
  <comments>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/693329/comments/0" datecreated="2010-12-22T10:26:49.690789+00:00">
      <person>Philip Stoev</person>
      <subject>
<![CDATA[Assertion `!is_interleave_error' failed on low optimizer_search_depth]]>      </subject>
      <content>
<![CDATA[As already reported in mysql bug http://bugs.mysql.com/bug.php?id=54429 , using low values for optimizer_search_depth causes an easy crash on multiple-table joins.

The RQG sometimes generates joins involving many tables. In order to restrict the total optimization time per query, and thus run more queries per test run, optimizer_search_depth must be safe to use and not assert.

assertion:
mysqld: sql_select.cc:5498: bool greedy_search(JOIN*, table_map, uint, uint): Assertion `!is_interleave_error' failed.

backtrace:

#8  0x006b0d98 in __assert_fail () from /lib/libc.so.6
#9  0x0831785c in greedy_search (join=0xae688eb0, remaining_tables=55, search_depth=4, prune_level=1) at sql_select.cc:5498
#10 0x08316ebc in choose_plan (join=0xae688eb0, join_tables=55) at sql_select.cc:5120
#11 0x0831205f in make_join_statistics (join=0xae688eb0, tables_arg=0xae631c80, conds=0x0, keyuse_array=0xae68dbec) at sql_select.cc:3216
#12 0x08309e93 in JOIN::optimize (this=0xae688eb0) at sql_select.cc:956
#13 0x0830fa81 in mysql_select (thd=0xb1fda70, rref_pointer_array=0xb1ff50c, tables=0xae631c80, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147764736, result=0xae64b8b0,
    unit=0xb1ff16c, select_lex=0xb1ff408) at sql_select.cc:2607
#14 0x0830800d in handle_select (thd=0xb1fda70, lex=0xb1ff110, result=0xae64b8b0, setup_tables_done_option=0) at sql_select.cc:286
#15 0x082a3400 in execute_sqlcom_select (thd=0xb1fda70, all_tables=0xae631c80) at sql_parse.cc:5070
#16 0x08299e1b in mysql_execute_command (thd=0xb1fda70) at sql_parse.cc:2234
#17 0x082a599e in mysql_parse (thd=0xb1fda70,
    rawbuf=0xae631940 "SELECT table2.f4  FROM t1  AS table1  LEFT  JOIN t1  AS table2  LEFT  JOIN t2  AS table3  LEFT  JOIN t3  AS table4  ON table3 .f1  = table4.f3  ON table2 .f1  LEFT  JOIN t4  AS table5  JOIN t5  ON tab"...,
    length=262, found_semicolon=0xae983228) at sql_parse.cc:6077
#18 0x08297904 in dispatch_command (command=COM_QUERY, thd=0xb1fda70,
    packet=0xb217c31 "SELECT table2.f4  FROM t1  AS table1  LEFT  JOIN t1  AS table2  LEFT  JOIN t2  AS table3  LEFT  JOIN t3  AS table4  ON table3 .f1  = table4.f3  ON table2 .f1  LEFT  JOIN t4  AS table5  JOIN t5  ON tab"...,
    packet_length=265) at sql_parse.cc:1210
#19 0x08296d6e in do_command (thd=0xb1fda70) at sql_parse.cc:903
#20 0x08293e4a in handle_one_connection (arg=0xb1fda70) at sql_connect.cc:1154
#21 0x00821919 in start_thread () from /lib/libpthread.so.0
#22 0x0076acce in clone () from /lib/libc.so.6

test case:

SET SESSION optimizer_search_depth = 4;

CREATE TABLE t1 (f1 int,f2 int,f3 int,f4 int) ;
INSERT IGNORE INTO t1 VALUES (0,0,2,0),(NULL,0,2,0);

CREATE TABLE t2 (f1 int) ;
CREATE TABLE t3 (f3 int,PRIMARY KEY (f3)) ;
CREATE TABLE t4 (f5 int) ;
CREATE TABLE t5 (f2 int) ;

SELECT alias2.f4  FROM t1  AS alias1
LEFT    JOIN t1  AS alias2
        LEFT  JOIN t2  AS alias3
        LEFT  JOIN t3  AS alias4  ON alias3.f1 = alias4.f3
        ON alias2.f1
LEFT    JOIN t4  AS alias5
        JOIN t5  ON alias5.f5
ON alias2.f3  ON alias1.f2   ;]]>      </content>
    </comment>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/693329/comments/1" datecreated="2010-12-22T10:32:52.177586+00:00">
      <person>Philip Stoev</person>
      <subject>
<![CDATA[Re: Assertion `!is_interleave_error' failed on low optimizer_search_depth]]>      </subject>
      <content>
<![CDATA[Timour reports this bug is in Sergey's code. A patch is available from the mysql bug report. ]]>      </content>
    </comment>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/693329/comments/2" datecreated="2011-04-06T12:49:26.309165+00:00">
      <person>Philip Stoev</person>
      <subject>
<![CDATA[Re: Assertion `!is_interleave_error' failed on low optimizer_search_depth]]>      </subject>
      <content>
<![CDATA[Here is another test case:


--source include/have_innodb.inc
SET SESSION optimizer_search_depth=4;

CREATE TABLE t1 ( f6 int)  ENGINE=InnoDB;

CREATE TABLE t2 ( f1 int) ;

CREATE TABLE t3 ( f4 int) ;

CREATE TABLE t4 ( f1 int)  ENGINE=InnoDB;

CREATE TABLE t5 ( f1 int) ;

CREATE TABLE t6 ( f3 int NOT NULL , PRIMARY KEY (f3)) ;

SELECT t2.f1
FROM t1
RIGHT JOIN t2 JOIN t3 ON t2.f1
RIGHT JOIN t4
LEFT JOIN t5
LEFT JOIN t6 ON t5.f1 = t6.f3 ON t4.f1 ON t3.f4 ON t1.f6 ;
]]>      </content>
    </comment>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/693329/comments/3" datecreated="2011-04-06T12:50:42.514944+00:00">
      <person>Philip Stoev</person>
      <subject>
<![CDATA[Re: Assertion `!is_interleave_error' failed on low optimizer_search_depth]]>      </subject>
      <content>
<![CDATA[Still repeatable with 


revision-id: psergey@askmonty.org-20110404083808-xc0xr5u0x2nj7q9j
date: 2011-04-04 12:38:08 +0400
build-date: 2011-04-06 15:50:31 +0300
revno: 2963
branch-nick: maria-5.3
]]>      </content>
    </comment>
  </comments>
</launchpad-bug>
