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

Assertion `element->all_tables.is_empty()' failed in tdc_assert_clean_share on SELECT

    XMLWordPrintable

Details

    • Can result in hang or crash

    Description

      INSTALL SONAME 'ha_connect';
      CREATE GLOBAL TEMPORARY TABLE t (c INT) ENGINE=Connect ON COMMIT DELETE ROWS;
      LOCK TABLES t WRITE;
      TRUNCATE t;
      SELECT * FROM t;
      

      Leads to:

      MDEV-35915 CS 12.2.0 228260ead7d9343e81a6d73bc0eb7ec96718d917 (Debug, Clang 21.1.3-20250923) Build 27/12/2025

      mariadbd: /test/bb-12.2-nikita-global-tmp_dbg/sql/table_cache.cc:479: void tdc_assert_clean_share(TDC_element *): Assertion `element->all_tables.is_empty()' failed.
      

      MDEV-35915 CS 12.2.0 228260ead7d9343e81a6d73bc0eb7ec96718d917 (Debug, Clang 21.1.3-20250923) Build 27/12/2025

      Core was generated by `/test/MDEV-35915_v9_MD271225-mariadb-12.2.0-linux-x86_64-dbg/bin/mariadbd --no-'.
      Program terminated with signal SIGABRT, Aborted.
      #0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:44
       
      [Current thread is 1 (LWP 1415960)]
      (gdb) bt
      #0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:44
      #1  __pthread_kill_internal (signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:78
      #2  __GI___pthread_kill (threadid=<optimized out>, signo=signo@entry=6)at ./nptl/pthread_kill.c:89
      #3  0x00007e5e56e4526e in __GI_raise (sig=sig@entry=6)at ../sysdeps/posix/raise.c:26
      #4  0x00007e5e56e288ff in __GI_abort () at ./stdlib/abort.c:79
      #5  0x00007e5e56e2881b in __assert_fail_base (fmt=0x7e5e56fd01e8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x5b8c69dc4db5 "element->all_tables.is_empty()", file=file@entry=0x5b8c69d0c480 "/test/bb-12.2-nikita-global-tmp_dbg/sql/table_cache.cc", line=line@entry=479, function=function@entry=0x5b8c69ce1b6f "void tdc_assert_clean_share(TDC_element *)") at ./assert/assert.c:94
      #6  0x00007e5e56e3b507 in __assert_fail (assertion=0x5b8c69dc4db5 "element->all_tables.is_empty()", file=0x5b8c69d0c480 "/test/bb-12.2-nikita-global-tmp_dbg/sql/table_cache.cc", line=479, function=0x5b8c69ce1b6f "void tdc_assert_clean_share(TDC_element *)")at ./assert/assert.c:103
      #7  0x00005b8c6acc8ad6 in tdc_assert_clean_share (element=0x7e5d28041228)at /test/bb-12.2-nikita-global-tmp_dbg/sql/table_cache.cc:479
      #8  0x00005b8c6acc6e41 in tdc_delete_share_from_hash (element=0x7e5d28041228)at /test/bb-12.2-nikita-global-tmp_dbg/sql/table_cache.cc:532
      #9  0x00005b8c6acc7c51 in tdc_release_share (share=0x7e5d28041790)at /test/bb-12.2-nikita-global-tmp_dbg/sql/table_cache.cc:1011
      #10 0x00005b8c6a82bd85 in open_table (thd=0x7e5d28000d58, table_list=0x7e5d2801a548, ot_ctx=0x7e5e4fffbb78)at /test/bb-12.2-nikita-global-tmp_dbg/sql/sql_base.cc:2526
      #11 0x00005b8c6a8305b0 in open_and_process_table (thd=0x7e5d28000d58, tables=0x7e5d2801a548, counter=0x7e5e4fffbc2c, flags=0, prelocking_strategy=0x7e5e4fffbc90, has_prelocking_list=false, ot_ctx=0x7e5e4fffbb78)at /test/bb-12.2-nikita-global-tmp_dbg/sql/sql_base.cc:4293
      #12 0x00005b8c6a82f3eb in open_tables (thd=0x7e5d28000d58, options=@0x7e5d28006734: {m_options = DDL_options_st::OPT_NONE}, start=0x7e5e4fffbc40, counter=0x7e5e4fffbc2c, flags=0, prelocking_strategy=0x7e5e4fffbc90)at /test/bb-12.2-nikita-global-tmp_dbg/sql/sql_base.cc:4776
      #13 0x00005b8c6a8321aa in open_and_lock_tables (thd=0x7e5d28000d58, options=@0x7e5d28006734: {m_options = DDL_options_st::OPT_NONE}, tables=0x7e5d2801a548, derived=true, flags=0, prelocking_strategy=0x7e5e4fffbc90)at /test/bb-12.2-nikita-global-tmp_dbg/sql/sql_base.cc:5764
      #14 0x00005b8c6a6b483e in open_and_lock_tables (thd=0x7e5d28000d58, tables=0x7e5d2801a548, derived=true, flags=0)at /test/bb-12.2-nikita-global-tmp_dbg/sql/sql_base.h:544
      #15 0x00005b8c6a9951ca in execute_sqlcom_select (thd=0x7e5d28000d58, all_tables=0x7e5d2801a548)at /test/bb-12.2-nikita-global-tmp_dbg/sql/sql_parse.cc:6109
      #16 0x00005b8c6a98bcf3 in mysql_execute_command (thd=0x7e5d28000d58, is_called_from_prepared_stmt=false)at /test/bb-12.2-nikita-global-tmp_dbg/sql/sql_parse.cc:3971
      #17 0x00005b8c6a984c18 in mysql_parse (thd=0x7e5d28000d58, rawbuf=0x7e5d28019e80 "SELECT * FROM t", length=15, parser_state=0x7e5e4fffda10)at /test/bb-12.2-nikita-global-tmp_dbg/sql/sql_parse.cc:7911
      #18 0x00005b8c6a9823f9 in dispatch_command (command=COM_QUERY, thd=0x7e5d28000d58, packet=0x7e5d2800b1f9 "SELECT * FROM t", packet_length=15, blocking=true)at /test/bb-12.2-nikita-global-tmp_dbg/sql/sql_parse.cc:1898
      #19 0x00005b8c6a98569a in do_command (thd=0x7e5d28000d58, blocking=true)at /test/bb-12.2-nikita-global-tmp_dbg/sql/sql_parse.cc:1437
      #20 0x00005b8c6ab7804e in do_handle_one_connection (connect=0x5b8c6de0a298, put_in_cache=true)at /test/bb-12.2-nikita-global-tmp_dbg/sql/sql_connect.cc:1414
      #21 0x00005b8c6ab77e31 in handle_one_connection (arg=0x5b8c6de92648)at /test/bb-12.2-nikita-global-tmp_dbg/sql/sql_connect.cc:1326
      #22 0x00007e5e56e9ca94 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #23 0x00007e5e56f29c3c in clone3 ()at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      While for debug builds the crash is immediate, for optimized builds it is slightly delayed, and a correct error is shown:

      MDEV-35915 CS 12.2.0 228260ead7d9343e81a6d73bc0eb7ec96718d917 (Optimized, Clang 21.1.3-20250923) Build 27/12/2025

      12.2.0-opt>SELECT * FROM t;
      ERROR 1478 (HY000): Table storage engine 'CONNECT' does not support the create option 'TEMPORARY'
      12.2.0-opt>
      12.2.0-opt>exit
      Bye
      

      Yet:

      MDEV-35915 CS 12.2.0 228260ead7d9343e81a6d73bc0eb7ec96718d917 (Optimized, Clang 21.1.3-20250923) Build 27/12/2025

      Core was generated by `/test/MDEV-35915_v9_MD271225-mariadb-12.2.0-linux-x86_64-opt/bin/mariadbd --no-'.
      Program terminated with signal SIGSEGV, Segmentation fault.
      #0  inline_mysql_mutex_lock (that=0x198, src_line=261, src_file=<optimized out>)at /test/bb-12.2-nikita-global-tmp_opt/include/mysql/psi/mysql_thread.h:745
      745	  if (psi_likely(that->m_psi != NULL))
      [Current thread is 1 (LWP 1415927)]
      (gdb) bt
      #0  inline_mysql_mutex_lock (that=0x198, src_line=261, src_file=<optimized out>)at /test/bb-12.2-nikita-global-tmp_opt/include/mysql/psi/mysql_thread.h:745
      #1  tc_remove_table (table=0x7fabbc033eb8)at /test/bb-12.2-nikita-global-tmp_opt/sql/table_cache.cc:261
      #2  0x00005f4358dc589b in close_thread_tables (thd=thd@entry=0x7fabbc000c68)at /test/bb-12.2-nikita-global-tmp_opt/sql/sql_base.cc:1019
      #3  0x00005f4358dc7fa7 in Locked_tables_list::unlock_locked_tables (this=0x7fabbc004ea8, thd=0x7fabbc000c68)at /test/bb-12.2-nikita-global-tmp_opt/sql/sql_base.cc:2752
      #4  0x00005f4358ddd2eb in THD::cleanup (this=0x7fabbc000c68)at /test/bb-12.2-nikita-global-tmp_opt/sql/sql_class.cc:1689
      #5  0x00005f4358ba07fe in unlink_thd (thd=0x7fabbc033eb8, thd@entry=0x7fabbc000c68)at /test/bb-12.2-nikita-global-tmp_opt/sql/mysqld.cc:2868
      #6  0x00005f4358fecadd in do_handle_one_connection (connect=<optimized out>, connect@entry=0x5f435ab8f9b8, put_in_cache=true)at /test/bb-12.2-nikita-global-tmp_opt/sql/sql_connect.cc:1425
      #7  0x00005f4358fec81f in handle_one_connection (arg=arg@entry=0x5f435ab8f9b8)at /test/bb-12.2-nikita-global-tmp_opt/sql/sql_connect.cc:1326
      #8  0x00005f43591b17c9 in pfs_spawn_thread (arg=0x5f435ab32978)at /test/bb-12.2-nikita-global-tmp_opt/storage/perfschema/pfs.cc:2198
      #9  0x00007faceac9ca94 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #10 0x00007facead29c3c in clone3 ()at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      Attachments

        Issue Links

          Activity

            People

              nikitamalyavin Nikita Malyavin
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              1 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.