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

Assertion `thd->mdl_context.is_lock_owner(MDL_key::TABLE, db.str, table_name.str, MDL_SHARED)' failed in mysql_rm_table_no_locks on DROP TABLE, including via scripts/mariadb-install-db

Details

    Description

      SET innodb_compression_default=1;
      CREATE TEMPORARY TABLE t (c INT);
      SET GLOBAL innodb_compression_level=0;
      TRUNCATE t;
      DROP TABLE t;
      

      Leads to:

      10.5.27 0e27351028a4888b0da271e2089bf1f847620396 (Debug)

      10.5.27-dbg>TRUNCATE t;
      ERROR 1030 (HY000): Got error 140 "Wrong create options" from storage engine InnoDB
       
      10.5.27-dbg>DROP TABLE t;
      ERROR 2013 (HY000): Lost connection to MySQL server during query
      

      On optimized we see:

      10.5.27 0e27351028a4888b0da271e2089bf1f847620396 (Optimized)

      10.5.27-opt>TRUNCATE t;
      ERROR 1030 (HY000): Got error 140 "Wrong create options" from storage engine InnoDB
       
      10.5.27-opt>DROP TABLE t;
      ERROR 1051 (42S02): Unknown table 'test.t'
      

      Interestingly, on optimized, SHOW CREATE TABLE sees the table, DROP TABLE does not (though the DROP still happens):

      10.5.27 0e27351028a4888b0da271e2089bf1f847620396 (Optimized)

      10.5.27-opt>TRUNCATE t;
      ERROR 1030 (HY000): Got error 140 "Wrong create options" from storage engine InnoDB
       
      10.5.27-opt>SHOW CREATE TABLE t;
      +-------+-------------------------------------------------------------------------------------------------------------------------------------------------+
      | Table | Create Table                                                                                                                                    |
      +-------+-------------------------------------------------------------------------------------------------------------------------------------------------+
      | t     | CREATE TEMPORARY TABLE `t` (
        `c` int(11) DEFAULT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci `PAGE_COMPRESSED`='ON' |
      +-------+-------------------------------------------------------------------------------------------------------------------------------------------------+
      1 row in set (0.000 sec)
       
      10.5.27-opt>DROP TABLE t;
      ERROR 1051 (42S02): Unknown table 'test.t'
      

      Debug assertion:

      10.5.27 0e27351028a4888b0da271e2089bf1f847620396 (Debug)

      mariadbd: /test/10.5_dbg/sql/sql_table.cc:2445: int mysql_rm_table_no_locks(THD*, TABLE_LIST*, bool, bool, bool, bool, bool, bool): Assertion `thd->mdl_context.is_lock_owner(MDL_key::TABLE, db.str, table_name.str, MDL_SHARED)' failed.
      

      10.5.27 0e27351028a4888b0da271e2089bf1f847620396 (Debug)

      Core was generated by `/test/MD130824-mariadb-10.5.27-linux-x86_64-dbg/bin/mariadbd --no-defaults --ma'.
      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
       
      warning: 44	./nptl/pthread_kill.c: No such file or directory
      [Current thread is 1 (LWP 567478)]
      (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  0x0000143067e4526e in __GI_raise (sig=sig@entry=6)at ../sysdeps/posix/raise.c:26
      #4  0x0000143067e288ff in __GI_abort () at ./stdlib/abort.c:79
      #5  0x0000143067e2881b in __assert_fail_base (fmt=0x143067fd01e8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x5eba1369c418 "thd->mdl_context.is_lock_owner(MDL_key::TABLE, db.str, table_name.str, MDL_SHARED)", file=file@entry=0x5eba1369bb58 "/test/10.5_dbg/sql/sql_table.cc", line=line@entry=2445, function=function@entry=0x5eba1369c330 "int mysql_rm_table_no_locks(THD*, TABLE_LIST*, bool, bool, bool, bool, bool, bool)") at ./assert/assert.c:94
      #6  0x0000143067e3b507 in __assert_fail (assertion=0x5eba1369c418 "thd->mdl_context.is_lock_owner(MDL_key::TABLE, db.str, table_name.str, MDL_SHARED)", file=0x5eba1369bb58 "/test/10.5_dbg/sql/sql_table.cc", line=2445, function=0x5eba1369c330 "int mysql_rm_table_no_locks(THD*, TABLE_LIST*, bool, bool, bool, bool, bool, bool)") at ./assert/assert.c:103
      #7  0x00005eba12a58a95 in mysql_rm_table_no_locks (thd=thd@entry=0x143000000d58, tables=tables@entry=0x143000012f50, if_exists=if_exists@entry=false, drop_temporary=drop_temporary@entry=false, drop_view=drop_view@entry=false, drop_sequence=drop_sequence@entry=false, dont_log_query=false, dont_free_locks=false)at /test/10.5_dbg/sql/sql_table.cc:2445
      #8  0x00005eba12a5a8fa in mysql_rm_table (thd=thd@entry=0x143000000d58, tables=tables@entry=0x143000012f50, if_exists=<optimized out>, drop_temporary=<optimized out>, drop_sequence=<optimized out>, dont_log_query=dont_log_query@entry=false)at /test/10.5_dbg/sql/sql_table.cc:2164
      #9  0x00005eba129a58b8 in mysql_execute_command (thd=thd@entry=0x143000000d58)at /test/10.5_dbg/sql/sql_parse.cc:5079
      #10 0x00005eba129aa479 in mysql_parse (thd=thd@entry=0x143000000d58, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x143065b012a0, 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:8229
      #11 0x00005eba129ac9f9 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x143000000d58, packet=packet@entry=0x14300000aaf9 "DROP TABLE t", packet_length=packet_length@entry=12, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false)at /test/10.5_dbg/sql/sql_class.h:238
      #12 0x00005eba129af1cd in do_command (thd=0x143000000d58)at /test/10.5_dbg/sql/sql_parse.cc:1376
      #13 0x00005eba12ae26ac in do_handle_one_connection (connect=<optimized out>, connect@entry=0x5eba15ebeef8, put_in_cache=put_in_cache@entry=true)at /test/10.5_dbg/sql/sql_connect.cc:1417
      #14 0x00005eba12ae29d2 in handle_one_connection (arg=arg@entry=0x5eba15ebeef8)at /test/10.5_dbg/sql/sql_connect.cc:1319
      #15 0x00005eba12f32f78 in pfs_spawn_thread (arg=0x5eba15eb3268)at /test/10.5_dbg/storage/perfschema/pfs.cc:2201
      #16 0x0000143067e9ca94 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #17 0x0000143067f29c3c in clone3 ()at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      Bug confirmed present in:
      MariaDB: 10.5.27 (dbg), 10.5.27 (opt)

      Bug (or feature/syntax) confirmed not present in:
      MariaDB: 10.6.20 (dbg), 10.6.20 (opt), 10.11.10 (dbg), 10.11.10 (opt), 11.1.7 (dbg), 11.1.7 (opt), 11.2.6 (dbg), 11.2.6 (opt), 11.4.4 (dbg), 11.4.4 (opt), 11.5.2 (dbg), 11.5.2 (opt), 11.6.1 (dbg), 11.6.1 (opt)

      Attachments

        Issue Links

          Activity

            marko Hi! The issue is deemed to be in the starting of multiple instances of mariadb-install-db at the same time. Can you please try the script as posted here? Thank you

            Example run:

            CS 11.2.6 e91a79945822def1452787f825e6047c6a64dbd9 (Debug)

            /test/MD090924-mariadb-11.2.6-linux-x86_64-dbg$ while true; do
              rm -rf data[0-9] [0-9].log
              for((i=0;i<10;i++)){
                ./scripts/mariadb-install-db --no-defaults --force --auth-root-authentication-method=normal --basedir=${PWD} --datadir=./data${i} >> ${i}.log 2>&1 &
              }
              wait %1 %2 %3 %4 %5 %6 %7 %8 %9 %10 2>/dev/null
              if grep -qi 'mysql_rm_table_no_locks' [0-9].log; then
                break
              fi
            done
            grep 'mysql_rm_table_no_locks' [0-9].log
            [1] 219032
            [2] 219033
            [3] 219034
            [4] 219035
            [5] 219037
            [6] 219040
            [7] 219042
            [8] 219047
            [9] 219049
            [10] 219057
            [1] 223819
            [2] 223821
            [3] 223822
            [4] 223824
            [5] 223826
            [6] 223830
            [7] 223833
            [8] 223836
            [9] 223845
            [10] 223851
            3.log:mariadbd: /test/11.2_dbg/sql/sql_table.cc:1524: int mysql_rm_table_no_locks(THD*, TABLE_LIST*, const LEX_CSTRING*, DDL_LOG_STATE*, bool, bool, bool, bool, bool, bool): Assertion `thd->mdl_context.is_lock_owner(MDL_key::TABLE, db.str, table_name.str, MDL_SHARED)' failed.
            

            Roel Roel Van de Paar added a comment - marko Hi! The issue is deemed to be in the starting of multiple instances of mariadb-install-db at the same time. Can you please try the script as posted here ? Thank you Example run: CS 11.2.6 e91a79945822def1452787f825e6047c6a64dbd9 (Debug) /test/MD090924-mariadb-11.2.6-linux-x86_64-dbg$ while true; do rm -rf data[0-9] [0-9].log for((i=0;i<10;i++)){ ./scripts/mariadb-install-db --no-defaults --force --auth-root-authentication-method=normal --basedir=${PWD} --datadir=./data${i} >> ${i}.log 2>&1 & } wait %1 %2 %3 %4 %5 %6 %7 %8 %9 %10 2>/dev/null if grep -qi 'mysql_rm_table_no_locks' [0-9].log; then break fi done grep 'mysql_rm_table_no_locks' [0-9].log [1] 219032 [2] 219033 [3] 219034 [4] 219035 [5] 219037 [6] 219040 [7] 219042 [8] 219047 [9] 219049 [10] 219057 [1] 223819 [2] 223821 [3] 223822 [4] 223824 [5] 223826 [6] 223830 [7] 223833 [8] 223836 [9] 223845 [10] 223851 3.log:mariadbd: /test/11.2_dbg/sql/sql_table.cc:1524: int mysql_rm_table_no_locks(THD*, TABLE_LIST*, const LEX_CSTRING*, DDL_LOG_STATE*, bool, bool, bool, bool, bool, bool): Assertion `thd->mdl_context.is_lock_owner(MDL_key::TABLE, db.str, table_name.str, MDL_SHARED)' failed.

            Roel, can you try with --external-locking to work around the logic change of MDEV-24393?

            marko Marko Mäkelä added a comment - Roel , can you try with --external-locking to work around the logic change of MDEV-24393 ?
            Roel Roel Van de Paar added a comment - - edited

            marko Yes, same outcome:

            CS 11.2.6 e91a79945822def1452787f825e6047c6a64dbd9 (Debug)

            /test/MD090924-mariadb-11.2.6-linux-x86_64-dbg$ while true; do
              rm -rf data[0-9] [0-9].log
              for((i=0;i<10;i++)){
                ./scripts/mariadb-install-db --no-defaults --force --external-locking --auth-root-authentication-method=normal --basedir=${PWD} --datadir=./data${i} >> ${i}.log 2>&1 &
              }
              wait %1 %2 %3 %4 %5 %6 %7 %8 %9 %10 2>/dev/null
              if grep -qi 'mysql_rm_table_no_locks' [0-9].log; then
                break
              fi
            done
            grep 'mysql_rm_table_no_locks' [0-9].log
            [1] 1702720
            [2] 1702721
            [3] 1702722
            [4] 1702724
            [5] 1702727
            [6] 1702730
            [7] 1702732
            [8] 1702737
            [9] 1702740
            [10] 1702751
            [1] 1704662
            [2] 1704663
            [3] 1704664
            [4] 1704665
            [5] 1704667
            [6] 1704669
            [7] 1704672
            [8] 1704675
            [9] 1704680
            [10] 1704686
            5.log:mariadbd: /test/11.2_dbg/sql/sql_table.cc:1524: int mysql_rm_table_no_locks(THD*, TABLE_LIST*, const LEX_CSTRING*, DDL_LOG_STATE*, bool, bool, bool, bool, bool, bool): Assertion `thd->mdl_context.is_lock_owner(MDL_key::TABLE, db.str, table_name.str, MDL_SHARED)' failed.
            

            Roel Roel Van de Paar added a comment - - edited marko Yes, same outcome: CS 11.2.6 e91a79945822def1452787f825e6047c6a64dbd9 (Debug) /test/MD090924-mariadb-11.2.6-linux-x86_64-dbg$ while true; do rm -rf data[0-9] [0-9].log for((i=0;i<10;i++)){ ./scripts/mariadb-install-db --no-defaults --force --external-locking --auth-root-authentication-method=normal --basedir=${PWD} --datadir=./data${i} >> ${i}.log 2>&1 & } wait %1 %2 %3 %4 %5 %6 %7 %8 %9 %10 2>/dev/null if grep -qi 'mysql_rm_table_no_locks' [0-9].log; then break fi done grep 'mysql_rm_table_no_locks' [0-9].log [1] 1702720 [2] 1702721 [3] 1702722 [4] 1702724 [5] 1702727 [6] 1702730 [7] 1702732 [8] 1702737 [9] 1702740 [10] 1702751 [1] 1704662 [2] 1704663 [3] 1704664 [4] 1704665 [5] 1704667 [6] 1704669 [7] 1704672 [8] 1704675 [9] 1704680 [10] 1704686 5.log:mariadbd: /test/11.2_dbg/sql/sql_table.cc:1524: int mysql_rm_table_no_locks(THD*, TABLE_LIST*, const LEX_CSTRING*, DDL_LOG_STATE*, bool, bool, bool, bool, bool, bool): Assertion `thd->mdl_context.is_lock_owner(MDL_key::TABLE, db.str, table_name.str, MDL_SHARED)' failed.

            4.log shows a crash on DROP TABLE tmp_user_sys, completely outside InnoDB:

            scripts/mysql_system_tables.sql

            CREATE TEMPORARY TABLE tmp_user_sys LIKE global_priv;
            INSERT INTO tmp_user_sys (Host,User,Priv) VALUES ('localhost','mariadb.sys','{"access":0,"plugin":"mysql_native_password","authentication_string":"","account_locked":true,"password_last_changed":0}');
            INSERT IGNORE INTO global_priv SELECT * FROM tmp_user_sys WHERE 0 <> @need_sys_user_creation;
            DROP TABLE tmp_user_sys;
            

            The cmake -DWITH_DBUG_TRACE=ON trace in mariadb.95.0.trace does not tell me anything, but hopefully it is useful to someone who can fix this non-InnoDB bug.

            Would the crash be avoided if each mariadb-install-db used their own tmpdir?

            marko Marko Mäkelä added a comment - 4.log shows a crash on DROP TABLE tmp_user_sys , completely outside InnoDB: scripts/mysql_system_tables.sql CREATE TEMPORARY TABLE tmp_user_sys LIKE global_priv; INSERT INTO tmp_user_sys (Host, User ,Priv) VALUES ( 'localhost' , 'mariadb.sys' , '{"access":0,"plugin":"mysql_native_password","authentication_string":"","account_locked":true,"password_last_changed":0}' ); INSERT IGNORE INTO global_priv SELECT * FROM tmp_user_sys WHERE 0 <> @need_sys_user_creation; DROP TABLE tmp_user_sys; The cmake -DWITH_DBUG_TRACE=ON trace in mariadb.95.0.trace does not tell me anything, but hopefully it is useful to someone who can fix this non-InnoDB bug. Would the crash be avoided if each mariadb-install-db used their own tmpdir ?
            Roel Roel Van de Paar added a comment - - edited

            Excellent. Thank you marko; setting an individual tmpdir fixes the problem.

            while true; do
              rm -rf data[0-9] tmp[0-9] [0-9].log
              for((i=0;i<10;i++)){
                mkdir tmp${i}
              }
              for((i=0;i<10;i++)){
                scripts/mariadb-install-db --no-defaults --force --auth-root-authentication-method=normal --basedir=${PWD} --datadir=${PWD}/data${i} --tmpdir=${PWD}/tmp${i} >> ${i}.log 2>&1 &
              }
              wait %1 %2 %3 %4 %5 %6 %7 %8 %9 %10 2>/dev/null
              if grep -qi 'mysql_rm_table_no_locks' [0-9].log; then
                break
              fi
            done
            grep 'mysql_rm_table_no_locks' [0-9].log
            

            Does not crash/end. This remind me of the days of creating reducer.sh where so many little tweaks - just like this - were required to make issues reproducible 95%+ of the time.

            sitano Hi! Please see the discussion above and please check from your end also.

            So while the secondary issue with mariadb-install-db on all versions looks to be resolved, the original testcase issue (10.5 only) stands as-is, and as discussed/agreed earlier in the ticket that one won't be fixed. I have removed any 10.6+ versions and will close the bug as 'Won't fix' for the original issue.

            Roel Roel Van de Paar added a comment - - edited Excellent. Thank you marko ; setting an individual tmpdir fixes the problem. while true ; do rm -rf data[0-9] tmp[0-9] [0-9].log for ((i=0;i<10;i++)){ mkdir tmp${i} } for ((i=0;i<10;i++)){ scripts /mariadb-install-db --no-defaults --force --auth-root-authentication-method=normal --basedir=${PWD} --datadir=${PWD} /data ${i} --tmpdir=${PWD} /tmp ${i} >> ${i}.log 2>&1 & } wait %1 %2 %3 %4 %5 %6 %7 %8 %9 %10 2> /dev/null if grep -qi 'mysql_rm_table_no_locks' [0-9].log; then break fi done grep 'mysql_rm_table_no_locks' [0-9].log Does not crash/end. This remind me of the days of creating reducer.sh where so many little tweaks - just like this - were required to make issues reproducible 95%+ of the time. sitano Hi! Please see the discussion above and please check from your end also. So while the secondary issue with mariadb-install-db on all versions looks to be resolved, the original testcase issue (10.5 only) stands as-is, and as discussed/agreed earlier in the ticket that one won't be fixed. I have removed any 10.6+ versions and will close the bug as 'Won't fix' for the original issue.

            People

              Unassigned Unassigned
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

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