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

MariaDB crash on WITH RECURSIVE large query

    XMLWordPrintable

Details

    Description

      This should be fixed in these version as per the MDEV-17024
      But it is not. Latest MariaDB 10.3.23 version still crashing due it.

      Here is the same test case.

      CREATE TABLE t1 (  YEAR int(4), d1 date , d2 date) ;
      INSERT INTO t1 VALUES (2018,'2018-01-01','2018-09-20');
      CREATE TABLE t2 (id int, tm date);
      INSERT INTO t2 VALUES (1,'2018-08-30'),(2,'2018-08-30'),(3,'2018-08-30');
      CREATE TABLE t3 (id int, tm date);
      INSERT INTO t3 VALUES (1,'2018-08-30'),(2,'2018-08-30');
       
      WITH RECURSIVE 
      cte AS
        (SELECT  YEAR(t1.d1) AS YEAR, t1.d1 AS st, t1.d1 + INTERVAL 1 MONTH AS fn FROM t1
         UNION ALL 
         SELECT YEAR(cte.st + INTERVAL 1 MONTH), cte.st + INTERVAL 1 MONTH,  t1.d2 + INTERVAL 1 DAY
         FROM cte JOIN t1
         WHERE cte.st + INTERVAL 1 MONTH < t1.d2 ),
                     
      cte2 AS (SELECT YEAR, COUNT(*) 
              FROM cte JOIN t2 ON t2.tm BETWEEN cte.st AND cte.fn),
      cte3 AS (SELECT YEAR, COUNT(*) 
              FROM cte JOIN t3 ON t3.tm BETWEEN cte.st AND cte.fn)
      SELECT 1 FROM t1 JOIN cte2 USING (YEAR) JOIN cte3 USING (YEAR);
      

      2020-05-29 12:02:06 0 [Note] /home/nilnandan/Downloads/10.3.23/bin/mysqld: ready for connections.
      Version: '10.3.23-MariaDB'  socket: '/tmp/mysql_sandbox10323.sock'  port: 10323  MariaDB Server
      pure virtual method called
      terminate called without an active exception
      200529 12:03:51 [ERROR] mysqld got signal 6 ;
      This could be because you hit a bug. It is also possible that this binary
      or one of the libraries it was linked against is corrupt, improperly built,
      or misconfigured. This error can also be caused by malfunctioning hardware.
       
      To report this bug, see https://mariadb.com/kb/en/reporting-bugs
       
      We will try our best to scrape up some info that will hopefully help
      diagnose the problem, but since we have already crashed,
      something is definitely wrong and this may fail.
       
      Server version: 10.3.23-MariaDB
      key_buffer_size=134217728
      read_buffer_size=131072
      max_used_connections=1
      max_threads=153
      thread_count=7
      It is possible that mysqld could use up to
      key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 467423 K  bytes of memory
      Hope that's ok; if not, decrease some variables in the equation.
       
      Thread pointer: 0x7fb7fc000c08
      Attempting backtrace. You can use the following information to find out
      where mysqld died. If you see no messages after this, something went
      terribly wrong...
      stack_bottom = 0x7fb864de7e90 thread_stack 0x49000
      /home/nilnandan/Downloads/10.3.23/bin/mysqld(my_print_stacktrace+0x2e)[0x55c4e919bade]
      mysys/stacktrace.c:270(my_print_stacktrace)[0x55c4e8bf4caf]
      /lib/x86_64-linux-gnu/libpthread.so.0(+0x12890)[0x7fb869edb890]
      /lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7fb868ba9e97]
      linux/raise.c:51(__GI_raise)[0x7fb868bab801]
      /usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0x8c957)[0x7fb869386957]
      /home/nilnandan/Downloads/10.3.23/bin/mysqld(_ZN10__cxxabiv111__terminateEPFvvE+0x6)[0x55c4e92532f6]
      libsupc++/eh_terminate.cc:42(__cxxabiv1::__terminate(void (*)()))[0x55c4e9253323]
      /home/nilnandan/Downloads/10.3.23/bin/mysqld(+0xe2015f)[0x55c4e921b15f]
      /home/nilnandan/Downloads/10.3.23/bin/mysqld(_ZN7handler22ha_rnd_init_with_errorEb+0x17)[0x55c4e8bfb5a7]
      sql/handler.h:3104(handler::ha_rnd_init_with_error(bool))[0x55c4e8acfaab]
      sql/table.cc:8191(TABLE::insert_all_rows_into_tmp_table(THD*, TABLE*, TMP_TABLE_PARAM*, bool))[0x55c4e89e31bb]
      sql/sql_derived.cc:1142(mysql_derived_fill(THD*, LEX*, TABLE_LIST*))[0x55c4e89e2cbc]
      sql/sql_derived.cc:199(mysql_handle_single_derived(LEX*, TABLE_LIST*, unsigned int))[0x55c4e8a4e859]
      sql/sql_select.cc:12825(st_join_table::preread_init())[0x55c4e8a4ec18]
      sql/sql_select.cc:19649(sub_select(JOIN*, st_join_table*, bool))[0x55c4e8a7176b]
      sql/sql_select.cc:19222(do_select)[0x55c4e8a71983]
      sql/sql_select.cc:3897(JOIN::exec())[0x55c4e8a6fe9a]
      sql/sql_select.cc:4303(mysql_select(THD*, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*))[0x55c4e89e2fa9]
      sql/sql_derived.cc:1113(mysql_derived_fill(THD*, LEX*, TABLE_LIST*))[0x55c4e89e2cbc]
      sql/sql_derived.cc:199(mysql_handle_single_derived(LEX*, TABLE_LIST*, unsigned int))[0x55c4e8a4e859]
      sql/sql_select.cc:12825(st_join_table::preread_init())[0x55c4e8a4ec18]
      sql/sql_select.cc:19649(sub_select(JOIN*, st_join_table*, bool))[0x55c4e8a43dbc]
      sql/sql_class.h:3884(evaluate_join_record(JOIN*, st_join_table*, int))[0x55c4e8a4ea9e]
      sql/sql_select.cc:19689(sub_select(JOIN*, st_join_table*, bool))[0x55c4e8a43dbc]
      sql/sql_class.h:3884(evaluate_join_record(JOIN*, st_join_table*, int))[0x55c4e8a4ea9e]
      sql/sql_select.cc:19689(sub_select(JOIN*, st_join_table*, bool))[0x55c4e8a7176b]
      sql/sql_select.cc:19222(do_select)[0x55c4e8a71983]
      sql/sql_select.cc:3897(JOIN::exec())[0x55c4e8a6fe9a]
      sql/sql_select.cc:4303(mysql_select(THD*, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*))[0x55c4e8a7099c]
      sql/sql_select.cc:382(handle_select(THD*, LEX*, select_result*, unsigned long))[0x55c4e892570f]
      sql/sql_parse.cc:6294(execute_sqlcom_select(THD*, TABLE_LIST*))[0x55c4e8a1850b]
      sql/sql_parse.cc:3820(mysql_execute_command(THD*))[0x55c4e8a1ed62]
      sql/sql_parse.cc:7817(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x55c4e8a205cf]
      sql/sql_parse.cc:1919(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x55c4e8a221ab]
      sql/sql_parse.cc:1404(do_command(THD*))[0x55c4e8af6c56]
      sql/sql_connect.cc:1403(do_handle_one_connection(CONNECT*))[0x55c4e8af6d6d]
      nptl/pthread_create.c:463(start_thread)[0x7fb869ed06db]
      /lib/x86_64-linux-gnu/libc.so.6(clone+0x3f)[0x7fb868c8c88f]
       
      Trying to get some variables.
      Some pointers may be invalid and cause the dump to abort.
      Query (0x7fb7fc00f610): WITH RECURSIVE  cte AS   (SELECT  YEAR(t1.d1) AS YEAR, t1.d1 AS st, t1.d1 + INTERVAL 1 MONTH AS fn FROM t1    UNION ALL     SELECT YEAR(cte.st + INTERVAL 1 MONTH), cte.st + INTERVAL 1 MONTH,  t1.d2 + INTERVAL 1 DAY    FROM cte JOIN t1    WHERE cte.st + INTERVAL 1 MONTH < t1.d2 ),                 cte2 AS (SELECT YEAR, COUNT(*)          FROM cte JOIN t2 ON t2.tm BETWEEN cte.st AND cte.fn), cte3 AS (SELECT YEAR, COUNT(*)          FROM cte JOIN t3 ON t3.tm BETWEEN cte.st AND cte.fn) SELECT 1 FROM t1 JOIN cte2 USING (YEAR) JOIN cte3 USING (YEAR)
      Connection ID (thread ID): 10
      Status: NOT_KILLED
      

      Attachments

        Issue Links

          Activity

            People

              igor Igor Babaev
              niljoshi Nilnandan Joshi
              Votes:
              1 Vote for this issue
              Watchers:
              7 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.