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

Server crashes in Explain_node::print_explain_json_for_children upon query with cte and view

    XMLWordPrintable

    Details

      Description

      CREATE TABLE t (f INT PRIMARY KEY);
      INSERT INTO t VALUES (1),(2);
      CREATE VIEW v AS SELECT f, COUNT(*) FROM t GROUP BY f;
      ANALYZE FORMAT=JSON WITH cte AS (SELECT MAX(f) FROM v WHERE 0) SELECT * FROM cte;
       
      # Cleanup
      DROP VIEW v;
      DROP TABLE t;
      

      10.3 c8cece91

      #3  <signal handler called>
      #4  0x0000560d0495b7e0 in Explain_node::print_explain_json_for_children (this=0x7f82980a69d0, query=0x7f82980189f8, writer=0x7f82aa3d3700, is_analyze=true) at /data/src/10.3/sql/sql_explain.cc:686
      #5  0x0000560d0495c1b0 in Explain_select::print_explain_json (this=0x7f82980a69d0, query=0x7f82980189f8, writer=0x7f82aa3d3700, is_analyze=true) at /data/src/10.3/sql/sql_explain.cc:884
      #6  0x0000560d0495f12f in Explain_table_access::print_explain_json (this=0x7f82980a7f08, query=0x7f82980189f8, writer=0x7f82aa3d3700, is_analyze=true) at /data/src/10.3/sql/sql_explain.cc:1764
      #7  0x0000560d0495cb78 in Explain_basic_join::print_explain_json_interns (this=0x7f82980a7df0, query=0x7f82980189f8, writer=0x7f82aa3d3700, is_analyze=true) at /data/src/10.3/sql/sql_explain.cc:1063
      #8  0x0000560d0495c5c6 in Explain_select::print_explain_json (this=0x7f82980a7df0, query=0x7f82980189f8, writer=0x7f82aa3d3700, is_analyze=true) at /data/src/10.3/sql/sql_explain.cc:962
      #9  0x0000560d04959b34 in Explain_query::print_explain_json (this=0x7f82980189f8, output=0x7f82980a8420, is_analyze=true) at /data/src/10.3/sql/sql_explain.cc:229
      #10 0x0000560d04959869 in Explain_query::send_explain (this=0x7f82980189f8, thd=0x7f8298000d90) at /data/src/10.3/sql/sql_explain.cc:172
      #11 0x0000560d047ad5a4 in execute_sqlcom_select (thd=0x7f8298000d90, all_tables=0x7f82980144a8) at /data/src/10.3/sql/sql_parse.cc:6351
      #12 0x0000560d047a3ebb in mysql_execute_command (thd=0x7f8298000d90) at /data/src/10.3/sql/sql_parse.cc:3870
      #13 0x0000560d047b1888 in mysql_parse (thd=0x7f8298000d90, rawbuf=0x7f8298012ad8 "ANALYZE FORMAT=JSON WITH cte AS (SELECT MAX(f) FROM v WHERE 0) SELECT * FROM cte", length=80, parser_state=0x7f82aa3d4530, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:7870
      #14 0x0000560d0479df49 in dispatch_command (command=COM_QUERY, thd=0x7f8298000d90, packet=0x7f8298008f31 "", packet_length=80, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:1852
      #15 0x0000560d0479c8e9 in do_command (thd=0x7f8298000d90) at /data/src/10.3/sql/sql_parse.cc:1398
      #16 0x0000560d0491d676 in do_handle_one_connection (connect=0x560d075005c0) at /data/src/10.3/sql/sql_connect.cc:1403
      #17 0x0000560d0491d3d2 in handle_one_connection (arg=0x560d075005c0) at /data/src/10.3/sql/sql_connect.cc:1308
      #18 0x0000560d052f140d in pfs_spawn_thread (arg=0x560d074e3540) at /data/src/10.3/storage/perfschema/pfs.cc:1869
      #19 0x00007f82b06c2609 in start_thread (arg=<optimized out>) at pthread_create.c:477
      #20 0x00007f82b05e7293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Reproducible on 10.3-10.7, with MyISAM, InnoDB, Aria alike.
      Not reproducible on 10.2.

      Additionally, with an extra ANALYZE before the one with cte, it turns into an assertion failure on debug builds, while remains the crash above on non-debug builds.

      CREATE TABLE t (f INT PRIMARY KEY);
      INSERT INTO t VALUES (1),(2);
      CREATE VIEW v AS SELECT f, COUNT(*) FROM t GROUP BY f;
       
      ANALYZE FORMAT=JSON SELECT MAX(f) FROM v WHERE 0;
      ANALYZE FORMAT=JSON WITH cte AS (SELECT MAX(f) FROM v WHERE 0) SELECT * FROM cte;
       
      # Cleanup
      DROP VIEW v;
      DROP TABLE t;
      

      10.3 c8cece91 debug

      mysqld: /data/src/10.3/sql/protocol.cc:597: void Protocol::end_statement(): Assertion `0' failed.
      211107  1:03:42 [ERROR] mysqld got signal 6 ;
       
      #7  0x00007f039f38cf36 in __GI___assert_fail (assertion=0x55a20111c350 "0", file=0x55a20111bf48 "/data/src/10.3/sql/protocol.cc", line=597, function=0x55a20111c2f8 "void Protocol::end_statement()") at assert.c:101
      #8  0x000055a2003c5dcc in Protocol::end_statement (this=0x7f0388001348) at /data/src/10.3/sql/protocol.cc:597
      #9  0x000055a2004dfcca in dispatch_command (command=COM_QUERY, thd=0x7f0388000d90, packet=0x7f0388008f31 "ANALYZE FORMAT=JSON SELECT MAX(f) FROM v WHERE 0", packet_length=48, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:2410
      #10 0x000055a2004dc8e9 in do_command (thd=0x7f0388000d90) at /data/src/10.3/sql/sql_parse.cc:1398
      #11 0x000055a20065d676 in do_handle_one_connection (connect=0x55a203a785c0) at /data/src/10.3/sql/sql_connect.cc:1403
      #12 0x000055a20065d3d2 in handle_one_connection (arg=0x55a203a785c0) at /data/src/10.3/sql/sql_connect.cc:1308
      #13 0x000055a20103140d in pfs_spawn_thread (arg=0x55a203a5b540) at /data/src/10.3/storage/perfschema/pfs.cc:1869
      #14 0x00007f039f553609 in start_thread (arg=<optimized out>) at pthread_create.c:477
      #15 0x00007f039f478293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              1 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.