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

Assertion `m_psi_batch_mode == PSI_BATCH_MODE_NONE' failed in handler::ha_close on UNION query when limiting tmp/heap size

    XMLWordPrintable

Details

    Description

      SET SESSION max_heap_table_size=16384;
      WITH RECURSIVE q (b) AS (SELECT 1 UNION ALL SELECT 1+b FROM q WHERE b<2000) SELECT MIN(q.b),MAX(q.b),AVG(q.b) FROM q, q AS q1;
      

      Leads to:

      10.5.4 6877ef9a7c9c7ee55d67e4baaf4e8f7b874c9f89

      mysqld: /test/10.5_dbg/sql/handler.cc:2965: int handler::ha_close(): Assertion `m_psi_batch_mode == PSI_BATCH_MODE_NONE' failed.
      

      10.5.4 6877ef9a7c9c7ee55d67e4baaf4e8f7b874c9f89

      Core was generated by `/test/MD060620-mariadb-10.5.4-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
      Program terminated with signal SIGABRT, Aborted.
      #0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6)
          at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
      [Current thread is 1 (Thread 0x1525be10c700 (LWP 2335918))]
      (gdb) bt
      #0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
      #1  0x000055629922b00d in my_write_core (sig=sig@entry=6) at /test/10.5_dbg/mysys/stacktrace.c:518
      #2  0x00005562989d4bbc in handle_fatal_signal (sig=6) at /test/10.5_dbg/sql/signal_handler.cc:330
      #3  <signal handler called>
      #4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
      #5  0x00001525c6a6a801 in __GI_abort () at abort.c:79
      #6  0x00001525c6a5a39a in __assert_fail_base (fmt=0x1525c6be17d8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x55629953db48 "m_psi_batch_mode == PSI_BATCH_MODE_NONE", file=file@entry=0x55629953c562 "/test/10.5_dbg/sql/handler.cc", line=line@entry=2965, function=function@entry=0x556299540bf0 <handler::ha_close()::__PRETTY_FUNCTION__> "int handler::ha_close()") at assert.c:92
      #7  0x00001525c6a5a412 in __GI___assert_fail (assertion=assertion@entry=0x55629953db48 "m_psi_batch_mode == PSI_BATCH_MODE_NONE", file=file@entry=0x55629953c562 "/test/10.5_dbg/sql/handler.cc", line=line@entry=2965, function=function@entry=0x556299540bf0 <handler::ha_close()::__PRETTY_FUNCTION__> "int handler::ha_close()") at assert.c:101
      #8  0x00005562989dbe5b in handler::ha_close (this=0x1525a4c83ca0) at /test/10.5_dbg/sql/handler.cc:2965
      #9  0x0000556298779ed5 in create_internal_tmp_table_from_heap (thd=thd@entry=0x1525a4c15088, table=table@entry=0x1525a4ca70a0, start_recinfo=<optimized out>, recinfo=recinfo@entry=0x1525a4c79400, error=error@entry=135, ignore_last_dupp_key_error=ignore_last_dupp_key_error@entry=true, is_duplicate=0x1525be109fc0) at /test/10.5_dbg/sql/sql_select.cc:19872
      #10 0x000055629883aa86 in TABLE::insert_all_rows_into_tmp_table (this=0x1525a4c800a0, thd=thd@entry=0x1525a4c15088, tmp_table=0x1525a4ca70a0, tmp_table_param=0x1525a4c793c0, with_cleanup=with_cleanup@entry=true) at /test/10.5_dbg/sql/table.cc:8985
      #11 0x00005562986dd9fd in TABLE_LIST::fill_recursive (this=this@entry=0x1525a4c77d38, thd=thd@entry=0x1525a4c15088) at /test/10.5_dbg/sql/sql_derived.cc:1148
      #12 0x00005562986ddd9e in mysql_derived_fill (thd=0x1525a4c15088, lex=0x1525a4c18fd8, derived=0x1525a4c77d38) at /test/10.5_dbg/sql/sql_derived.cc:1240
      #13 0x00005562986dd8c3 in mysql_handle_single_derived (lex=0x1525a4c18fd8, derived=derived@entry=0x1525a4c77d38, phases=phases@entry=96) at /test/10.5_dbg/sql/sql_derived.cc:206
      #14 0x000055629876fbe9 in st_join_table::preread_init (this=this@entry=0x1525a4caa4d8) at /test/10.5_dbg/sql/sql_select.cc:13597
      #15 0x0000556298780679 in join_init_read_record (tab=0x1525a4caa4d8) at /test/10.5_dbg/sql/sql_select.cc:21567
      #16 0x00005562988bf6f6 in JOIN_TAB_SCAN::open (this=0x1525a4caaf28) at /test/10.5_dbg/sql/sql_join_cache.cc:3357
      #17 0x00005562988c2b0b in JOIN_CACHE::join_matching_records (this=0x1525a4caac28, skip_last=false) at /test/10.5_dbg/sql/sql_join_cache.cc:2260
      #18 0x00005562988c2370 in JOIN_CACHE::join_records (this=this@entry=0x1525a4caac28, skip_last=skip_last@entry=false) at /test/10.5_dbg/sql/sql_join_cache.cc:2092
      #19 0x0000556298770462 in sub_select_cache (join=0x1525a4c78d30, join_tab=0x1525a4caa4d8, end_of_records=<optimized out>) at /test/10.5_dbg/sql/sql_select.cc:20423
      #20 0x0000556298768b79 in evaluate_join_record (join=join@entry=0x1525a4c78d30, join_tab=join_tab@entry=0x1525a4caa130, error=error@entry=0) at /test/10.5_dbg/sql/sql_select.cc:20852
      #21 0x0000556298770056 in sub_select (join=0x1525a4c78d30, join_tab=0x1525a4caa130, end_of_records=<optimized out>) at /test/10.5_dbg/sql/sql_select.cc:20668
      #22 0x00005562987a8d44 in do_select (procedure=0x0, join=0x1525a4c78d30) at /test/10.5_dbg/sql/sql_select.cc:20163
      #23 JOIN::exec_inner (this=this@entry=0x1525a4c78d30) at /test/10.5_dbg/sql/sql_select.cc:4475
      #24 0x00005562987a935f in JOIN::exec (this=this@entry=0x1525a4c78d30) at /test/10.5_dbg/sql/sql_select.cc:4256
      #25 0x00005562987a7674 in mysql_select (thd=thd@entry=0x1525a4c15088, tables=<optimized out>, fields=@0x1525a4c76950: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1525a4c76f20, last = 0x1525a4c775a8, elements = 3}, <No data fields>}, conds=0x0, og_num=0, order=<optimized out>, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x1525a4c78d08, unit=0x1525a4c190a0, select_lex=0x1525a4c76800) at /test/10.5_dbg/sql/sql_select.cc:4680
      #26 0x00005562987a79a3 in handle_select (thd=thd@entry=0x1525a4c15088, lex=lex@entry=0x1525a4c18fd8, result=result@entry=0x1525a4c78d08, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.5_dbg/sql/sql_select.cc:417
      #27 0x00005562987313a0 in execute_sqlcom_select (thd=thd@entry=0x1525a4c15088, all_tables=0x1525a4c77600) at /test/10.5_dbg/sql/sql_parse.cc:6208
      #28 0x000055629872a4cc in mysql_execute_command (thd=thd@entry=0x1525a4c15088) at /test/10.5_dbg/sql/sql_parse.cc:3939
      #29 0x0000556298737322 in mysql_parse (thd=thd@entry=0x1525a4c15088, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x1525be10b350, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_dbg/sql/sql_parse.cc:7992
      #30 0x0000556298723e1c in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x1525a4c15088, packet=packet@entry=0x1525a4c67089 "", packet_length=packet_length@entry=125, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_dbg/sql/sql_parse.cc:1874
      #31 0x00005562987225f6 in do_command (thd=0x1525a4c15088) at /test/10.5_dbg/sql/sql_parse.cc:1355
      #32 0x000055629887d9f9 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x1525a81153a8, put_in_cache=put_in_cache@entry=true) at /test/10.5_dbg/sql/sql_connect.cc:1411
      #33 0x000055629887e115 in handle_one_connection (arg=arg@entry=0x1525a81153a8) at /test/10.5_dbg/sql/sql_connect.cc:1313
      #34 0x0000556298cdd104 in pfs_spawn_thread (arg=0x1525c5445888) at /test/10.5_dbg/storage/perfschema/pfs.cc:2201
      #35 0x00001525c774d6db in start_thread (arg=0x1525be10c700) at pthread_create.c:463
      #36 0x00001525c6b4b88f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Bug confirmed present in:
      MariaDB: 10.5.4 (dbg, 6877ef9a7c9c7ee55d67e4baaf4e8f7b874c9f89)

      Bug confirmed not present in:
      MariaDB: 10.1.46 (dbg), 10.1.46 (opt), 10.2.33 (dbg), 10.2.33 (opt), 10.3.24 (dbg), 10.3.24 (opt), 10.4.14 (dbg), 10.4.14 (opt), 10.5.4 (opt)
      MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.47 (dbg), 5.6.47 (opt), 5.7.29 (dbg), 5.7.29 (opt), 8.0.19 (dbg), 8.0.19 (opt)

      Interestingly, this bug does not crash the later revision 07d1c8567cbfe94398a9857c47fb9919cad42651. Perhaps a relevant change was made or the bug is now somehow masked? Output from that version;

      10.5.4 07d1c8567cbfe94398a9857c47fb9919cad42651

      10.5.4>SET SESSION max_heap_table_size=16384;
      Query OK, 0 rows affected (0.000 sec)
       
      10.5.4>WITH RECURSIVE q (b) AS (SELECT 1 UNION ALL SELECT 1+b FROM q WHERE b<2000) SELECT MIN(q.b),MAX(q.b),AVG(q.b) FROM q, q AS q1;
      +----------+----------+-----------+
      | MIN(q.b) | MAX(q.b) | AVG(q.b)  |
      +----------+----------+-----------+
      |        1 |     2000 | 1000.5000 |
      +----------+----------+-----------+
      1 row in set (0.692 sec)
      

      Attachments

        Issue Links

          Activity

            People

              igor Igor Babaev
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              6 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.