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

Assertion is_lock_owner on error returning from auto-create in mysql_admin_table

    XMLWordPrintable

Details

    • Can result in hang or crash

    Description

      --source include/have_partition.inc
       
      SET TIMESTAMP=2147483647;
      CREATE TABLE t (x INT) WITH SYSTEM VERSIONING PARTITION BY SYSTEM_TIME INTERVAL 1 HOUR AUTO;
      OPTIMIZE TABLE t;
       
      # cleanup
      DROP TABLE t;
      

      Leads to:

      CS 10.11.16 b29d3779e42f1cf65b1bbe84876767122dcc76c8 (Debug, Clang 18.1.3-11) Build 29/01/2026

      mariadbd: /test/10.11_dbg/sql/sql_base.cc:1036: void close_thread_table(THD *, TABLE **): Assertion `thd->mdl_context.is_lock_owner(MDL_key::TABLE, table->s->db.str, table->s->table_name.str, MDL_SHARED) || thd->mdl_context.is_lock_warrantee(MDL_key::TABLE, table->s->db.str, table->s->table_name.str, MDL_SHARED)' failed.
      

      CS 10.11.16 b29d3779e42f1cf65b1bbe84876767122dcc76c8 (Debug, Clang 18.1.3-11) Build 29/01/2026

      Core was generated by `/test/MD290126-mariadb-10.11.16-linux-x86_64-dbg/bin/mariadbd --no-defaults --m'.
      Program terminated with signal SIGABRT, Aborted.
      Download failed: Invalid argument.  Continuing without source file ./nptl/./nptl/pthread_kill.c.
      #0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:44
       
      [Current thread is 1 (LWP 2252996)]
      (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  0x000070d45704527e in __GI_raise (sig=sig@entry=6)at ../sysdeps/posix/raise.c:26
      #4  0x000070d4570288ff in __GI_abort () at ./stdlib/abort.c:79
      #5  0x000070d45702881b in __assert_fail_base (fmt=0x70d4571d01e8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x62022763406a "thd->mdl_context.is_lock_owner(MDL_key::TABLE, table->s->db.str, table->s->table_name.str, MDL_SHARED) || thd->mdl_context.is_lock_warrantee(MDL_key::TABLE, table->s->db.str, table->s->table_name.str,"..., file=file@entry=0x620227633d01 "/test/10.11_dbg/sql/sql_base.cc", line=line@entry=1036, function=function@entry=0x620227634041 "void close_thread_table(THD *, TABLE **)") at ./assert/assert.c:96
      #6  0x000070d45703b517 in __assert_fail (assertion=0x62022763406a "thd->mdl_context.is_lock_owner(MDL_key::TABLE, table->s->db.str, table->s->table_name.str, MDL_SHARED) || thd->mdl_context.is_lock_warrantee(MDL_key::TABLE, table->s->db.str, table->s->table_name.str,"..., file=0x620227633d01 "/test/10.11_dbg/sql/sql_base.cc", line=1036, function=0x620227634041 "void close_thread_table(THD *, TABLE **)")at ./assert/assert.c:105
      #7  0x0000620226596232 in close_thread_table (thd=0x70bd18000d58, table_ptr=0x70bd18000e50) at /test/10.11_dbg/sql/sql_base.cc:1029
      #8  0x00006202265969ff in close_thread_tables (thd=0x70bd18000d58)at /test/10.11_dbg/sql/sql_base.cc:1005
      #9  0x00006202265a1157 in open_and_lock_tables (thd=0x70bd18000d58, options=@0x70bd180065c0: {m_options = DDL_options_st::OPT_NONE}, tables=0x70bd18013520, derived=true, flags=0, prelocking_strategy=0x70d0770b3c50) at /test/10.11_dbg/sql/sql_base.cc:5791
      #10 0x000062022654fa9e in open_and_lock_tables (thd=0x70bd18000d58, tables=0x70bd18013520, derived=true, flags=0)at /test/10.11_dbg/sql/sql_base.h:519
      #11 0x0000620226845249 in open_only_one_table (thd=0x70bd18000d58, table=0x70bd18013520, repair_table_use_frm=false, is_view_operator_func=false) at /test/10.11_dbg/sql/sql_admin.cc:424
      #12 0x0000620226840385 in mysql_admin_table (thd=0x70bd18000d58, tables=0x70bd18013520, check_opt=0x70bd18006360, operator_name=0x620227e06858 <msg_optimize>, lock_type=TL_WRITE, org_open_for_modify=true, repair_table_use_frm=false, extra_open_options=0, prepare_func=0x0, operator_func=(int (handler::*)(class handler * const, class THD *, HA_CHECK_OPT *)) 0x620226a3f8e0 <handler::ha_optimize(THD*, st_ha_check_opt*)>, view_operator_func=0x0, is_cmd_replicated=true)at /test/10.11_dbg/sql/sql_admin.cc:640
      #13 0x0000620226844147 in Sql_cmd_optimize_table::execute (this=0x70bd18013c40, thd=0x70bd18000d58)at /test/10.11_dbg/sql/sql_admin.cc:1627
      #14 0x000062022665e9a9 in mysql_execute_command (thd=0x70bd18000d58, is_called_from_prepared_stmt=false)at /test/10.11_dbg/sql/sql_parse.cc:6201
      #15 0x000062022664c6e4 in mysql_parse (thd=0x70bd18000d58, rawbuf=0x70bd18013460 "optimize TABLE t", length=16, parser_state=0x70d0770b6a20) at /test/10.11_dbg/sql/sql_parse.cc:8223
      #16 0x0000620226649b89 in dispatch_command (command=COM_QUERY, thd=0x70bd18000d58, packet=0x70bd1800aee9 "", packet_length=16, blocking=true) at /test/10.11_dbg/sql/sql_parse.cc:1924
      #17 0x000062022664d293 in do_command (thd=0x70bd18000d58, blocking=true)at /test/10.11_dbg/sql/sql_parse.cc:1434
      #18 0x000062022682a889 in do_handle_one_connection (connect=0x620229f2c5a8, put_in_cache=true) at /test/10.11_dbg/sql/sql_connect.cc:1475
      #19 0x000062022682a622 in handle_one_connection (arg=0x620229e466c8)at /test/10.11_dbg/sql/sql_connect.cc:1387
      #20 0x000070d45709caa4 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #21 0x000070d457129c6c in clone3 ()at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      Bug Detection Matrix

          Rel    o/d  Build   Commit                                    UniqueID observed             
      CS  10.6   dbg  290126  bf686bb987766bce4ca842d12178d0c08710cab8  No bug found                  
      CS  10.6   opt  290126  bf686bb987766bce4ca842d12178d0c08710cab8  No bug found                  
      CS  10.11  dbg  290126  b29d3779e42f1cf65b1bbe84876767122dcc76c8  thd->mdl_context.is_lock_owner(MDL_key::TABLE, table->s->db.str, table->s->table_name.str, MDL_SHARED) || thd->mdl_context.is_lock_warrantee(MDL_key::TABLE, table->s->db.str, table->s->table_name.str, MDL_SHARED)|SIGABRT|close_thread_table|close_thread_tables|open_and_lock_tables|open_and_lock_tables
      CS  10.11  opt  290126  b29d3779e42f1cf65b1bbe84876767122dcc76c8  No bug found                                 
      CS  11.4   dbg  290126  ca39e66060d4735f91fd46d9784b4c91ed6746aa  No bug found                                   
      CS  11.4   opt  290126  ca39e66060d4735f91fd46d9784b4c91ed6746aa  No bug found                  
      CS  11.8   dbg  280126  8a0f327675e9b4a1e0ae2e3a97fe001122a9db03  No bug found                  
      CS  11.8   opt  280126  8a0f327675e9b4a1e0ae2e3a97fe001122a9db03  No bug found                  
      CS  12.2   dbg  290126  de72d02bffe6639ef0b7911966a3f85e3eba052f  No bug found                  
      CS  12.2   opt  290126  de72d02bffe6639ef0b7911966a3f85e3eba052f  No bug found                  
      CS  12.3   dbg  290126  5bcc115d773caac07d4afd42252e08f3905452b0  No bug found                  
      CS  12.3   opt  290126  5bcc115d773caac07d4afd42252e08f3905452b0  No bug found                  
      ES  10.5   dbg  040825  70586522eacf09d04d49962072e14325a75d8155  No bug found                  
      ES  10.5   opt  040825  70586522eacf09d04d49962072e14325a75d8155  No bug found                  
      ES  10.6   dbg  040825  9b794f34b48fb7eee490b6da44edc0f33a947447  No bug found                  
      ES  10.6   opt  040825  9b794f34b48fb7eee490b6da44edc0f33a947447  No bug found                  
      ES  11.4   dbg  040825  a1c03ccd54b582e75506687ee19b273ca897f261  No bug found                  
      ES  11.4   opt  040825  a1c03ccd54b582e75506687ee19b273ca897f261  No bug found                  
      ES  11.8   dbg  151025  780565c207e9ce0ebf7d8e3d59f223801447b619  No bug found
      ES  11.8   opt  151025  780565c207e9ce0ebf7d8e3d59f223801447b619  No bug found                  
      

      The assertion is happening after this commit

      commit 5597f877fecc6d033337efd5c6ad10afb7e8e753 (HEAD)
      Author: Aleksey Midenkov <midenok@gmail.com>
      Date:   Sun Jan 4 12:03:44 2026 +0300
       
          MDEV-33289 INTERVAL partitioning by system time does not work close to the end of timestamp range
          
          1. Fix empty part_elem->id in prep_alter_part_table().
          
             On auto-create newly added partition has id 0. It came from
             set_up_default_partitions() for new part_info
             (thd->work_part_info). vers_update_el_ids() can work only with
             unassigned ids (UINT_MAX32), so we assign it explicitly on pushing
             into tab_part_info.
          
          2. If range value is out of TIMESTAMP_MAX_VALUE set it to
             TIMESTAMP_MAX_VALUE, but only if the history partition is the last
             one, otherwise push ER_DATA_OUT_OF_RANGE. Error is to create
             multiple out-of-range partitions (e.g. with PARTITIONS clause in
             CREATE TABLE).
      

      Attachments

        Issue Links

          Activity

            People

              midenok Aleksey Midenkov
              ramesh Ramesh Sivaraman
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.