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

Crashes in MDL_key::mdl_key_init with lower-case-table-names=2

    XMLWordPrintable

Details

    Description

      Crashes in MDL lock in MDL_key::mdl_key_init with lower-case-table-names=2

      This problem needs a case insensitive file system to reproduce.

      It should be reproducible on Windows.

      It's reproducible on Linux if I make a case insensitive vfat filesystem, mount it using a loop device, and run MTR on it:

      truncate -s 18G /home/bar/CIFS
      mkdir /home/bar/CIFSDIR
      sudo losetup /dev/loop0 /home/bar/CIFS
      sudo mkfs.vfat /dev/loop0
      sudo mount -o uid=bar,gid=bar /dev/loop0 /home/bar/CIFSDIR
       
      ./mtr --tmpdir=/home/bar/tmpdir \
       --vardir=/home/bar/CIFSDIR/var \
       --do-test="(lowercase)"
      

      The crash happens if I add this script into the end of lowercase_table2.test:

      CREATE DATABASE Db1;
      ALTER DATABASE Db1 DEFAULT CHARACTER SET utf8;
      DROP DATABASE Db1;
      

      #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
      #1  0x00007ffff75bd8d9 in __GI_abort () at abort.c:79
      #2  0x00007ffff75bd7a9 in __assert_fail_base (fmt=0x7ffff7728af8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x15285c8 "mdl_namespace_arg == USER_LOCK || ok_for_lower_case_names(db)", 
          file=0x15284f0 "/home/bar/maria-git/server.10.4/sql/mdl.h", line=436, function=<optimized out>) at assert.c:92
      #3  0x00007ffff75cca66 in __GI___assert_fail (assertion=0x15285c8 "mdl_namespace_arg == USER_LOCK || ok_for_lower_case_names(db)", file=0x15284f0 "/home/bar/maria-git/server.10.4/sql/mdl.h", line=436, 
          function=0x1528520 "void MDL_key::mdl_key_init(MDL_key::enum_mdl_namespace, const char*, const char*)") at assert.c:101
      #4  0x000000000094dc8e in MDL_key::mdl_key_init (this=0x7ffff07a9b20, mdl_namespace_arg=MDL_key::SCHEMA, db=0x7fffa4014898 "Db1", name_arg=0x16d8289 "") at /home/bar/maria-git/server.10.4/sql/mdl.h:436
      #5  0x00000000009d90bd in MDL_request::init (this=0x7ffff07a9b00, mdl_namespace=MDL_key::SCHEMA, db_arg=0x7fffa4014898 "Db1", name_arg=0x16d8289 "", mdl_type_arg=MDL_EXCLUSIVE, mdl_duration_arg=MDL_TRANSACTION)
          at /home/bar/maria-git/server.10.4/sql/mdl.cc:1001
      #6  0x0000000000cbb631 in lock_schema_name (thd=0x7fffa4000d90, db=0x7fffa4014898 "Db1") at /home/bar/maria-git/server.10.4/sql/lock.cc:869
      #7  0x00000000007ee44f in mysql_alter_db_internal (thd=0x7fffa4000d90, db=0x7fffa40059f0, create_info=0x7ffff07aa268) at /home/bar/maria-git/server.10.4/sql/sql_db.cc:718
      #8  0x00000000007ee795 in mysql_alter_db (thd=0x7fffa4000d90, db=0x7fffa40059f0, create_info=0x7fffa4006200) at /home/bar/maria-git/server.10.4/sql/sql_db.cc:790
      #9  0x000000000084f59d in mysql_execute_command (thd=0x7fffa4000d90) at /home/bar/maria-git/server.10.4/sql/sql_parse.cc:5223
      #10 0x00000000008583a9 in mysql_parse (thd=0x7fffa4000d90, rawbuf=0x7fffa40147e8 "ALTER DATABASE Db1 DEFAULT CHARACTER SET utf8", length=45, parser_state=0x7ffff07ab380, is_com_multi=false, is_next_command=false)
          at /home/bar/maria-git/server.10.4/sql/sql_parse.cc:8010
      #11 0x0000000000844c88 in dispatch_command (command=COM_QUERY, thd=0x7fffa4000d90, packet=0x7fffa400ac41 "ALTER DATABASE Db1 DEFAULT CHARACTER SET utf8", packet_length=45, is_com_multi=false, is_next_command=false)
          at /home/bar/maria-git/server.10.4/sql/sql_parse.cc:1857
      

      A similar crash happens if I add this script into the end of lowercase_table2.test:

      CREATE DATABASE `#mysql50#D+b1`;
      ALTER DATABASE `#mysql50#D+b1` UPGRADE DATA DIRECTORY NAME;
      DROP DATABASE `#mysql50#D+b1`;
      

      #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
      #1  0x00007ffff75bd8d9 in __GI_abort () at abort.c:79
      #2  0x00007ffff75bd7a9 in __assert_fail_base (fmt=0x7ffff7728af8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", 
          assertion=0x15285c8 "mdl_namespace_arg == USER_LOCK || ok_for_lower_case_names(db)", file=0x15284f0 "/home/bar/maria-git/server.10.4/sql/mdl.h", line=436, function=<optimized out>)
          at assert.c:92
      #3  0x00007ffff75cca66 in __GI___assert_fail (assertion=0x15285c8 "mdl_namespace_arg == USER_LOCK || ok_for_lower_case_names(db)", 
          file=0x15284f0 "/home/bar/maria-git/server.10.4/sql/mdl.h", line=436, function=0x1528520 "void MDL_key::mdl_key_init(MDL_key::enum_mdl_namespace, const char*, const char*)")
          at assert.c:101
      #4  0x000000000094dc8e in MDL_key::mdl_key_init (this=0x7ffff07a97f0, mdl_namespace_arg=MDL_key::SCHEMA, db=0x7fffa40148c8 "#mysql50#D+b1", name_arg=0x16d8289 "")
          at /home/bar/maria-git/server.10.4/sql/mdl.h:436
      #5  0x00000000009d90bd in MDL_request::init (this=0x7ffff07a97d0, mdl_namespace=MDL_key::SCHEMA, db_arg=0x7fffa40148c8 "#mysql50#D+b1", name_arg=0x16d8289 "", mdl_type_arg=MDL_EXCLUSIVE, 
          mdl_duration_arg=MDL_TRANSACTION) at /home/bar/maria-git/server.10.4/sql/mdl.cc:1001
      #6  0x0000000000cbb631 in lock_schema_name (thd=0x7fffa4000d90, db=0x7fffa40148c8 "#mysql50#D+b1") at /home/bar/maria-git/server.10.4/sql/lock.cc:869
      #7  0x00000000007f0769 in mysql_upgrade_db (thd=0x7fffa4000d90, old_db=0x7fffa40059f0) at /home/bar/maria-git/server.10.4/sql/sql_db.cc:1690
      #8  0x000000000084f489 in mysql_execute_command (thd=0x7fffa4000d90) at /home/bar/maria-git/server.10.4/sql/sql_parse.cc:5212
      #9  0x00000000008583a9 in mysql_parse (thd=0x7fffa4000d90, rawbuf=0x7fffa40147e8 "ALTER DATABASE `#mysql50#D+b1` UPGRADE DATA DIRECTORY NAME", length=58, parser_state=0x7ffff07ab380, 
          is_com_multi=false, is_next_command=false) at /home/bar/maria-git/server.10.4/sql/sql_parse.cc:8010
      #10 0x0000000000844c88 in dispatch_command (command=COM_QUERY, thd=0x7fffa4000d90, packet=0x7fffa400ac41 "ALTER DATABASE `#mysql50#D+b1` UPGRADE DATA DIRECTORY NAME", packet_length=58, 
          is_com_multi=false, is_next_command=false) at /home/bar/maria-git/server.10.4/sql/sql_parse.cc:1857
      

      The crashes happens because mysql_alter_db_internal() and mysql_upgrade_db() do not normalize the database name. In case of lower-case-table-names>0 it should normalize the database name to lower case.

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.