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

Assertion `inited == NONE || table->open_by_handler' failed in int handler::ha_external_lock(THD *, int)

    XMLWordPrintable

Details

    • Not for Release Notes
    • Q3/2026 Server Maintenance

    Description

      --source include/have_innodb.inc
      CREATE TABLE t1 (a INT) ENGINE=InnoDB;
      INSERT INTO t1 VALUES (1);
      DELIMITER $$;
      CREATE FUNCTION f() RETURNS INT
      BEGIN
        EXECUTE IMMEDIATE 'INSERT INTO t1 VALUES (2)';
        RETURN 1;
      END;
      $$
      DELIMITER ;$$
      SELECT * FROM t1 WHERE a = f();
       
      #cleanup
      DROP FUNCTION f;
      DROP TABLE t1;
      

      Leads to

      MDEV-39518 CS 13.1.0 ba0a2e08727bc136c1b25d527f9441389d22bf7b (Debug, Clang 18.1.3-11) Build 30/06/2026

      mariadbd: /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/handler.cc:8000: int handler::ha_external_lock(THD *, int): Assertion `inited == NONE || table->open_by_handler' failed.
      

      MDEV-39518 CS 13.1.0 ba0a2e08727bc136c1b25d527f9441389d22bf7b (Debug, Clang 18.1.3-11) Build 30/06/2026

      Core was generated by `/test/mtest/MDEV-39518/MD300626-mariadb-13.1.0-linux-x86_64-dbg/bin/mariadbd --'.
      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 3387724)]
      (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  0x00007f2da4a4527e in __GI_raise (sig=sig@entry=6)at ../sysdeps/posix/raise.c:26
      #4  0x00007f2da4a288ff in __GI_abort () at ./stdlib/abort.c:79
      #5  0x00007f2da4a2881b in __assert_fail_base (fmt=0x7f2da4bd01e8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x569187770be3 "inited == NONE || table->open_by_handler", file=file@entry=0x56918776e6ae "/test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/handler.cc", line=line@entry=8000, function=function@entry=0x569187770ae1 "int handler::ha_external_lock(THD *, int)") at ./assert/assert.c:96
      #6  0x00007f2da4a3b517 in __assert_fail (assertion=0x569187770be3 "inited == NONE || table->open_by_handler", file=0x56918776e6ae "/test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/handler.cc", line=8000, function=0x569187770ae1 "int handler::ha_external_lock(THD *, int)")at ./assert/assert.c:105
      #7  0x00005691869efa5e in handler::ha_external_lock (this=0x770af40291f0, thd=0x770af4000d60, lock_type=2)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/handler.cc:8000
      #8  0x00005691863f8b22 in handler::ha_external_unlock (this=0x770af40291f0, thd=0x770af4000d60)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/handler.h:3772
      #9  0x0000569186bcb0b3 in unlock_external (thd=0x770af4000d60, table=0x770af401d150, count=1)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/lock.cc:791
      #10 0x0000569186bcb192 in mysql_unlock_tables (thd=0x770af4000d60, sql_lock=0x770af401d130, free_lock=false)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/lock.cc:482
      #11 0x0000569186bcb34c in mysql_unlock_tables (thd=0x770af4000d60, sql_lock=0x770af401d130)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/lock.cc:465
      #12 0x00005691864b05bd in close_thread_tables (thd=0x770af4000d60)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/sql_base.cc:993
      #13 0x00005691864afe49 in close_thread_tables_for_query (thd=0x770af4000d60)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/sql_base.cc:814
      #14 0x00005691865925f2 in mysql_execute_command (thd=0x770af4000d60, is_called_from_prepared_stmt=false)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/sql_parse.cc:5997
      #15 0x000056918685cac7 in sp_instr_stmt::exec_core (this=0x770af407d6a0, thd=0x770af4000d60, nextp=0x7f2da00b8968)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/sp_instr.cc:1281
      #16 0x0000569186859f96 in sp_lex_keeper::reset_lex_and_exec_core (this=0x770af407d6e0, thd=0x770af4000d60, nextp=0x7f2da00b8968, open_tables=false, instr=0x770af407d6a0, rerun_the_same_instr=false)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/sp_instr.cc:420
      #17 0x000056918685a70c in sp_lex_keeper::validate_lex_and_exec_core (this=0x770af407d6e0, thd=0x770af4000d60, nextp=0x7f2da00b8968, open_tables=false, instr=0x770af407d6a0)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/sp_instr.cc:599
      #18 0x000056918685bd39 in sp_instr_stmt::execute (this=0x770af407d6a0, thd=0x770af4000d60, nextp=0x7f2da00b8968)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/sp_instr.cc:1183
      #19 0x000056918645890c in sp_head::execute (this=0x770af407c150, thd=0x770af4000d60, merge_da_on_success=true)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/sp_head.cc:1292
      #20 0x000056918645bfaa in sp_head::execute_function (this=0x770af407c150, thd=0x770af4000d60, argp=0x0, argcount=0, return_value_fld=0x770af401dbe0, func_ctx=0x770af401b728, call_arena=0x770af401c230)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/sp_head.cc:2064
      #21 0x0000569186a13b1c in Item_sp::execute_impl (this=0x770af401b6c0, thd=0x770af4000d60, args=0x0, arg_count=0)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/item.cc:3110
      #22 0x0000569186a13474 in Item_sp::execute (this=0x770af401b6c0, thd=0x770af4000d60, null_value=0x770af401b676, args=0x0, arg_count=0)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/item.cc:3012
      #23 0x0000569186aa4608 in Item_func_sp::execute (this=0x770af401b600)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/item_func.cc:6768
      #24 0x0000569186aaf899 in Item_func_sp::val_int (this=0x770af401b600)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/item_func.h:4358
      #25 0x0000569186a43622 in Arg_comparator::compare_int_signed (this=0x770af401c328)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/item_cmpfunc.cc:1031
      #26 0x0000569186a5e17f in Arg_comparator::compare (this=0x770af401c328)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/item_cmpfunc.h:114
      #27 0x0000569186a46d01 in Item_func_eq::val_bool (this=0x770af401c260)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/item_cmpfunc.cc:1912
      #28 0x0000569186640c6e in evaluate_join_record (join=0x770af401d190, join_tab=0x770af401f300, error=0)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/sql_select.cc:24820
      #29 0x00005691865f2f3e in sub_select (join=0x770af401d190, join_tab=0x770af401f300, end_of_records=false)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/sql_select.cc:24719
      #30 0x000056918661aa35 in do_select (join=0x770af401d190, procedure=0x0)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/sql_select.cc:24230
      #31 0x0000569186619de1 in JOIN::exec_inner (this=0x770af401d190)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/sql_select.cc:5125
      #32 0x0000569186618fe0 in JOIN::exec (this=0x770af401d190)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/sql_select.cc:4913
      #33 0x00005691865f381c in mysql_select (thd=0x770af4000d60, tables=0x770af401ab30, fields=@0x770af401a748: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x770af401aac0, last = 0x770af401aac0, elements = 1}, <No data fields>}, conds=0x770af401c260, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2164525824, result=0x770af401d160, unit=0x770af40052a0, select_lex=0x770af401a490)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/sql_select.cc:5439
      #34 0x00005691865f32f5 in handle_select (thd=0x770af4000d60, lex=0x770af40051c0, result=0x770af401d160, setup_tables_done_option=0)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/sql_select.cc:636
      #35 0x000056918659444d in execute_sqlcom_select (thd=0x770af4000d60, all_tables=0x770af401ab30)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/sql_parse.cc:6217
      #36 0x000056918658913d in mysql_execute_command (thd=0x770af4000d60, is_called_from_prepared_stmt=false)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/sql_parse.cc:3991
      #37 0x0000569186581264 in mysql_parse (thd=0x770af4000d60, rawbuf=0x770af401a3f0 "SELECT * FROM t1 WHERE a = f()", length=30, parser_state=0x7f2da00bb9f0)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/sql_parse.cc:7945
      #38 0x000056918657e5ad in dispatch_command (command=COM_QUERY, thd=0x770af4000d60, packet=0x770af400b621 "", packet_length=30, blocking=true)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/sql_parse.cc:1903
      #39 0x0000569186581e13 in do_command (thd=0x770af4000d60, blocking=true)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/sql_parse.cc:1437
      #40 0x0000569186781b19 in do_handle_one_connection (connect=0x56919c221110, put_in_cache=true)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/sql_connect.cc:1503
      #41 0x00005691867818be in handle_one_connection (arg=0x56919c206210)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_dbg/sql/sql_connect.cc:1415
      #42 0x00007f2da4a9caa4 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #43 0x00007f2da4b29c6c in clone3 ()at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              ramesh Ramesh Sivaraman
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 1h 4m Original Estimate - 1h 4m
                  1h 4m
                  Remaining:
                  Time Spent - 1d 1h 20m Remaining Estimate - 3h 7m
                  3h 7m
                  Logged:
                  Time Spent - 1d 1h 20m Remaining Estimate - 3h 7m
                  1d 1h 20m

                  Git Integration

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