Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-12820

Assertion `join->best_read < double(...)' failed in greedy_search

    XMLWordPrintable

Details

    Description

      Note: it is likely to be a duplicate of MDEV-12817, but the failure is different here, so I'm filing it separately just in case.

      CREATE TABLE t1 (c1 INT);
      INSERT INTO t1 VALUES (1),(2);
       
      CREATE TABLE t2 (c2 INT);
      INSERT INTO t2 VALUES (3),(4);
       
      CREATE TABLE t3 (c3 INT);
      INSERT INTO t2 VALUES (5),(6);
       
      CREATE TABLE t4 (c4 INT);
      INSERT INTO t4 VALUES (7),(8);
       
      SELECT * FROM t1 LEFT JOIN ( ( SELECT * FROM t2 WHERE c2 IN ( SELECT c3 FROM t3 ) ) AS sq INNER JOIN t4 ) ON (c1 = c2);
      

      5.5 2e1428c0b552f2c80aa4b27edaaab8bde8966b22

      mysqld: /data/src/5.5/sql/sql_select.cc:6632: bool greedy_search(JOIN*, table_map, uint, uint): Assertion `join->best_read < double(1.79769313486231570815e+308L)' failed.
      170517  0:59:20 [ERROR] mysqld got signal 6 ;
       
      #7  0x00007f08ef9afee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
      #8  0x0000000000640227 in greedy_search (join=0x7f08ea5720b8, remaining_tables=15, search_depth=62, prune_level=1) at /data/src/5.5/sql/sql_select.cc:6632
      #9  0x000000000063f842 in choose_plan (join=0x7f08ea5720b8, join_tables=15) at /data/src/5.5/sql/sql_select.cc:6212
      #10 0x000000000073b6f9 in optimize_semijoin_nests (join=0x7f08ea5720b8, all_table_map=15) at /data/src/5.5/sql/opt_subselect.cc:2244
      #11 0x00000000006390c6 in make_join_statistics (join=0x7f08ea5720b8, tables_list=..., conds=0x0, keyuse_array=0x7f08ea5723d8) at /data/src/5.5/sql/sql_select.cc:3795
      #12 0x00000000006300ce in JOIN::optimize (this=0x7f08ea5720b8) at /data/src/5.5/sql/sql_select.cc:1234
      #13 0x0000000000636a65 in mysql_select (thd=0x7f08eb664060, rref_pointer_array=0x7f08eb667cf0, tables=0x7f08ea548328, wild_num=1, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f08ea572098, unit=0x7f08eb667388, select_lex=0x7f08eb667a68) at /data/src/5.5/sql/sql_select.cc:3085
      #14 0x000000000062d352 in handle_select (thd=0x7f08eb664060, lex=0x7f08eb6672d8, result=0x7f08ea572098, setup_tables_done_option=0) at /data/src/5.5/sql/sql_select.cc:319
      #15 0x00000000006067b3 in execute_sqlcom_select (thd=0x7f08eb664060, all_tables=0x7f08ea548328) at /data/src/5.5/sql/sql_parse.cc:4686
      #16 0x00000000005ffb26 in mysql_execute_command (thd=0x7f08eb664060) at /data/src/5.5/sql/sql_parse.cc:2234
      #17 0x000000000060937e in mysql_parse (thd=0x7f08eb664060, rawbuf=0x7f08ea548078 "SELECT * FROM t1 LEFT JOIN ( ( SELECT * FROM t2 WHERE c2 IN ( SELECT c3 FROM t3 ) ) AS sq INNER JOIN t4 ) ON (c1 = c2)", length=118, parser_state=0x7f08f1423650) at /data/src/5.5/sql/sql_parse.cc:5931
      #18 0x00000000005fd0b5 in dispatch_command (command=COM_QUERY, thd=0x7f08eb664060, packet=0x7f08ef35b061 "SELECT * FROM t1 LEFT JOIN ( ( SELECT * FROM t2 WHERE c2 IN ( SELECT c3 FROM t3 ) ) AS sq INNER JOIN t4 ) ON (c1 = c2)", packet_length=118) at /data/src/5.5/sql/sql_parse.cc:1079
      #19 0x00000000005fc26f in do_command (thd=0x7f08eb664060) at /data/src/5.5/sql/sql_parse.cc:793
      #20 0x00000000006fe951 in do_handle_one_connection (thd_arg=0x7f08eb664060) at /data/src/5.5/sql/sql_connect.cc:1268
      #21 0x00000000006fe6de in handle_one_connection (arg=0x7f08eb664060) at /data/src/5.5/sql/sql_connect.cc:1184
      #22 0x0000000000a0bae7 in pfs_spawn_thread (arg=0x7f08ec376fc0) at /data/src/5.5/storage/perfschema/pfs.cc:1015
      #23 0x00007f08f1056494 in start_thread (arg=0x7f08f1424700) at pthread_create.c:333
      #24 0x00007f08efa6c93f in clone () from /lib/x86_64-linux-gnu/libc.so.6
      

      The problem appeared in 5.5 tree with this revision:

      commit 6b97fe067db1b1d8e8dee56508e6d78a36e92481
      Author: Igor Babaev
      Date:   Tue May 9 00:41:45 2017 -0700
       
          Fixed the bugs mdev-12670 and mdev-12675.
          
          The code that blocked conversion of a IN subselect pedicate to a semi-join
          if it occurred in the ON expression of an outer join did not do it correctly.
          As a result, the conversion was blocked for IN subselect predicates
          encountered in ON expressions of INNER joins or in WHERE conditions
          of mergeable views / derived tables. This patch fixes this problem.
      

      Attachments

        Activity

          People

            igor Igor Babaev
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.