Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: N/A
    • Fix Version/s: 10.0.14
    • Component/s: None
    • Labels:

      Description

      In the following test case, EXPLAIN seems to acquire MDL.

      Console1:

      MariaDB [test]> SHOW CREATE TABLE myisam1;
      +---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
      | Table   | Create Table                                                                                                                                                                           |
      +---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
      | myisam1 | CREATE TABLE `myisam1` (
        `a` int(11) NOT NULL,
        `b2` int(11) DEFAULT NULL,
        PRIMARY KEY (`a`)
      ) ENGINE=MyISAM DEFAULT CHARSET=latin1
      /*!50100 PARTITION BY KEY (a)
      PARTITIONS 3 */ |
      +---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
      1 row in set (0.00 sec)
      
      MariaDB [test]> START TRANSACTION;
      Query OK, 0 rows affected (0.01 sec)
      
      MariaDB [test]> EXPLAIN SELECT * FROM myisam1 WHERE 0;
      +------+-------------+-------+------+---------------+------+---------+------+------+------------------+
      | id   | select_type | table | type | possible_keys | key  | key_len | ref  | rows | Extra            |
      +------+-------------+-------+------+---------------+------+---------+------+------+------------------+
      |    1 | SIMPLE      | NULL  | NULL | NULL          | NULL | NULL    | NULL | NULL | Impossible WHERE |
      +------+-------------+-------+------+---------------+------+---------+------+------+------------------+
      1 row in set (0.00 sec)
      

      Console2:

      MariaDB [test]> ALTER TABLE myisam1 CHANGE b2  b INT;
      Stage: 2 of 2 'enabling keys'      0% of stage done
      

      (it's frozen)

      Console3:

      MariaDB [(none)]> SELECT * FROM information_schema.METADATA_LOCK_INFO;
      +-----------+-------------------------+-----------------+----------------------+--------------+------------+
      | THREAD_ID | LOCK_MODE               | LOCK_DURATION   | LOCK_TYPE            | TABLE_SCHEMA | TABLE_NAME |
      +-----------+-------------------------+-----------------+----------------------+--------------+------------+
      |         5 | MDL_INTENTION_EXCLUSIVE | MDL_STATEMENT   | Global read lock     |              |            |
      |         4 | MDL_SHARED_READ         | MDL_TRANSACTION | Table metadata lock  | test         | myisam1    |
      |         5 | MDL_SHARED_NO_WRITE     | MDL_TRANSACTION | Table metadata lock  | test         | myisam1    |
      |         5 | MDL_INTENTION_EXCLUSIVE | MDL_TRANSACTION | Schema metadata lock | test         |            |
      +-----------+-------------------------+-----------------+----------------------+--------------+------------+
      

      Not sure if this is a bug. If it isn't, I suggest to document non-obvious cases when a MDL is acquired. (When doing something similar to this, I locked metadata for some minutes, in production.)

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            serg Sergei Golubchik added a comment -

            I think it's not very surprising — EXPLAIN SELECT acquires metadata locks, just like SELECT does. Because EXPLAIN needs to know table metadata and, sometimes, data too.

            Show
            serg Sergei Golubchik added a comment - I think it's not very surprising — EXPLAIN SELECT acquires metadata locks, just like SELECT does. Because EXPLAIN needs to know table metadata and, sometimes, data too.
            Hide
            greenman Ian Gilfillan added a comment -

            I have added a note about EXPLAIN acquiring MDL in the KB.

            Show
            greenman Ian Gilfillan added a comment - I have added a note about EXPLAIN acquiring MDL in the KB.

              People

              • Assignee:
                greenman Ian Gilfillan
                Reporter:
                f_razzoli Federico Razzoli
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: