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

Assertion `m_psi_batch_mode == PSI_BATCH_MODE_NONE' failed in handler::ha_close with derived_merge=off

    XMLWordPrintable

Details

    Description

      --source include/have_sequence.inc
       
      SET max_heap_table_size= 1048576;
       
      CREATE TABLE t1 (a INT);
      INSERT INTO t1 VALUES (1),(2);
      CREATE TABLE t2 (a INT,  b INT, c VARCHAR(3), d VARCHAR(35));
      INSERT INTO t2 (a) SELECT seq FROM seq_1_to_130;
       
      SET optimizer_switch = 'derived_merge=off';
      SELECT * FROM t1, ( SELECT t2a.* FROM t2 AS t2a, t2 AS t2b ) AS sq;
       
      # Cleanup
      DROP TABLE t1, t2;
      

      10.5 244ff3e5

      mysqld: /data/src/10.5/sql/handler.cc:2952: int handler::ha_close(): Assertion `m_psi_batch_mode == PSI_BATCH_MODE_NONE' failed.
      200401 14:34:47 [ERROR] mysqld got signal 6 ;
       
      on=0x565012138120 <handler::ha_close()::__PRETTY_FUNCTION__> "int handler::ha_close()") at assert.c:101
      #8  0x000056501043730d in handler::ha_close (this=0x61b000041428) at /data/src/10.5/sql/handler.cc:2952
      #9  0x000056500fda75bf in create_internal_tmp_table_from_heap (thd=0x62b000069288, table=0x62300001f9a8, start_recinfo=0x623000020e58, recinfo=0x62b00003c490, error=135, ignore_last_dupp_key_error=true, is_duplicate=0x7f364007fec0) at /data/src/10.5/sql/sql_select.cc:19846
      #10 0x000056500ff337ed in select_unit::write_record (this=0x62b00003c418) at /data/src/10.5/sql/sql_union.cc:420
      #11 0x000056500ff30d88 in select_unit::send_data (this=0x62b00003c418, values=...) at /data/src/10.5/sql/sql_union.cc:156
      #12 0x000056500fdf79b3 in select_result_sink::send_data_with_check (this=0x62b00003c418, items=..., u=0x62b00003a5b0, sent=16849) at /data/src/10.5/sql/sql_class.h:5235
      #13 0x000056500fdb524b in end_send (join=0x62b00003c500, join_tab=0x629000263a90, end_of_records=false) at /data/src/10.5/sql/sql_select.cc:21795
      #14 0x00005650101304f4 in JOIN_CACHE::generate_full_extensions (this=0x6290002641f0, rec_ptr=0x624000064313 "\376P") at /data/src/10.5/sql/sql_join_cache.cc:2409
      #15 0x000056501012fd92 in JOIN_CACHE::join_matching_records (this=0x6290002641f0, skip_last=false) at /data/src/10.5/sql/sql_join_cache.cc:2301
      #16 0x000056501012e52a in JOIN_CACHE::join_records (this=0x6290002641f0, skip_last=false) at /data/src/10.5/sql/sql_join_cache.cc:2092
      #17 0x000056500fdab315 in sub_select_cache (join=0x62b00003c500, join_tab=0x6290002636e8, end_of_records=true) at /data/src/10.5/sql/sql_select.cc:20377
      #18 0x000056500fdab91f in sub_select (join=0x62b00003c500, join_tab=0x629000263340, end_of_records=true) at /data/src/10.5/sql/sql_select.cc:20548
      #19 0x000056500fdaa2c3 in do_select (join=0x62b00003c500, procedure=0x0) at /data/src/10.5/sql/sql_select.cc:20139
      #20 0x000056500fd383ba in JOIN::exec_inner (this=0x62b00003c500) at /data/src/10.5/sql/sql_select.cc:4463
      #21 0x000056500fd35a0c in JOIN::exec (this=0x62b00003c500) at /data/src/10.5/sql/sql_select.cc:4244
      #22 0x000056500fd39921 in mysql_select (thd=0x62b000069288, tables=0x62b000039730, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2201171004160, result=0x62b00003c418, unit=0x62b00003a5b0, select_lex=0x62b0000390d8) at /data/src/10.5/sql/sql_select.cc:4668
      #23 0x000056500fb9397c in mysql_derived_fill (thd=0x62b000069288, lex=0x62b00006d1c8, derived=0x62b00003ae10) at /data/src/10.5/sql/sql_derived.cc:1257
      #24 0x000056500fb8c363 in mysql_handle_single_derived (lex=0x62b00006d1c8, derived=0x62b00003ae10, phases=96) at /data/src/10.5/sql/sql_derived.cc:206
      #25 0x000056500fd79cee in st_join_table::preread_init (this=0x629000267650) at /data/src/10.5/sql/sql_select.cc:13571
      #26 0x000056500fdb2ac8 in join_init_read_record (tab=0x629000267650) at /data/src/10.5/sql/sql_select.cc:21541
      #27 0x000056501013466b in JOIN_TAB_SCAN::open (this=0x6290002680b8) at /data/src/10.5/sql/sql_join_cache.cc:3357
      #28 0x000056501012f6db in JOIN_CACHE::join_matching_records (this=0x629000267f80, skip_last=false) at /data/src/10.5/sql/sql_join_cache.cc:2260
      #29 0x000056501012e52a in JOIN_CACHE::join_records (this=0x629000267f80, skip_last=false) at /data/src/10.5/sql/sql_join_cache.cc:2092
      #30 0x000056500fdab315 in sub_select_cache (join=0x62b00003be98, join_tab=0x629000267650, end_of_records=true) at /data/src/10.5/sql/sql_select.cc:20377
      #31 0x000056500fdab91f in sub_select (join=0x62b00003be98, join_tab=0x6290002672a8, end_of_records=true) at /data/src/10.5/sql/sql_select.cc:20548
      #32 0x000056500fdaa2c3 in do_select (join=0x62b00003be98, procedure=0x0) at /data/src/10.5/sql/sql_select.cc:20139
      #33 0x000056500fd383ba in JOIN::exec_inner (this=0x62b00003be98) at /data/src/10.5/sql/sql_select.cc:4463
      #34 0x000056500fd35a0c in JOIN::exec (this=0x62b00003be98) at /data/src/10.5/sql/sql_select.cc:4244
      #35 0x000056500fd39921 in mysql_select (thd=0x62b000069288, tables=0x62b0000389d8, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x62b00003be68, unit=0x62b00006d290, select_lex=0x62b0000383a8) at /data/src/10.5/sql/sql_select.cc:4668
      #36 0x000056500fd0bc64 in handle_select (thd=0x62b000069288, lex=0x62b00006d1c8, result=0x62b00003be68, setup_tables_done_option=0) at /data/src/10.5/sql/sql_select.cc:417
      #37 0x000056500fc7dfae in execute_sqlcom_select (thd=0x62b000069288, all_tables=0x62b0000389d8) at /data/src/10.5/sql/sql_parse.cc:6168
      #38 0x000056500fc6c3d0 in mysql_execute_command (thd=0x62b000069288) at /data/src/10.5/sql/sql_parse.cc:3901
      #39 0x000056500fc88ffb in mysql_parse (thd=0x62b000069288, rawbuf=0x62b0000382a8 "SELECT * FROM t1, ( SELECT t2a.* FROM t2 AS t2a, t2 AS t2b ) AS sq", length=66, parser_state=0x7f3640082a50, is_com_multi=false, is_next_command=false) at /data/src/10.5/sql/sql_parse.cc:7953
      #40 0x000056500fc5edeb in dispatch_command (command=COM_QUERY, thd=0x62b000069288, packet=0x629000249289 "", packet_length=66, is_com_multi=false, is_next_command=false) at /data/src/10.5/sql/sql_parse.cc:1839
      #41 0x000056500fc5b820 in do_command (thd=0x62b000069288) at /data/src/10.5/sql/sql_parse.cc:1358
      #42 0x00005650100788ab in do_handle_one_connection (connect=0x61100001fd88, put_in_cache=true) at /data/src/10.5/sql/sql_connect.cc:1422
      #43 0x0000565010078146 in handle_one_connection (arg=0x61100001fc48) at /data/src/10.5/sql/sql_connect.cc:1319
      #44 0x0000565010d1601a in pfs_spawn_thread (arg=0x616000009108) at /data/src/10.5/storage/perfschema/pfs.cc:2201
      #45 0x00007f3649269fa3 in start_thread (arg=<optimized out>) at pthread_create.c:486
      #46 0x00007f3648ab84cf in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Execution plan with derived_merge=on as in the default optimizer_switch (no crash)

      # id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
      # 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	100.00	
      # 1	SIMPLE	t2a	ALL	NULL	NULL	NULL	NULL	130	100.00	Using join buffer (flat, BNL join)
      # 1	SIMPLE	t2b	ALL	NULL	NULL	NULL	NULL	130	100.00	Using join buffer (incremental, BNL join)
      # Warnings:
      # Note	1003	select `test`.`t1`.`a` AS `a`,`test`.`t2a`.`a` AS `a`,`test`.`t2a`.`b` AS `b`,`test`.`t2a`.`c` AS `c`,`test`.`t2a`.`d` AS `d` from `test`.`t1` join `test`.`t2` `t2a` join `test`.`t2` `t2b`
      

      Execution plan with derived_merge=off (crash)

      # EXPLAIN EXTENDED SELECT * FROM t1, ( SELECT t2a.* FROM t2 AS t2a, t2 AS t2b ) AS sq;
      # id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
      # 1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	100.00	
      # 1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	16900	100.00	Using join buffer (flat, BNL join)
      # 2	DERIVED	t2a	ALL	NULL	NULL	NULL	NULL	130	100.00	
      # 2	DERIVED	t2b	ALL	NULL	NULL	NULL	NULL	130	100.00	Using join buffer (flat, BNL join)
      # Warnings:
      # Note	1003	/* select#1 */ select `test`.`t1`.`a` AS `a`,`sq`.`a` AS `a`,`sq`.`b` AS `b`,`sq`.`c` AS `c`,`sq`.`d` AS `d` from `test`.`t1` join (/* select#2 */ select `test`.`t2a`.`a` AS `a`,`test`.`t2a`.`b` AS `b`,`test`.`t2a`.`c` AS `c`,`test`.`t2a`.`d` AS `d` from `test`.`t2` `t2a` join `test`.`t2` `t2b`) `sq`
      

      Reproducible with at least InnoDB, MyISAM, Aria.
      No obvious problem on a non-debug build.
      Not reproducible on 10.4.

      The failure started happening after the 5.7 performance schema merge. The first failing revision that I could compile was

      commit 7af733a5a2cb7f79ffb5ff0129cad6db6f3cc359
      Author: Sergei Golubchik
      Date:   Sat Feb 15 18:25:57 2020 +0100
       
          perfschema compilation, test and misc fixes
      

      Attachments

        Issue Links

          Activity

            People

              psergei Sergei Petrunia
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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