Metadata locks are a particular type of lock that has been supported since MariaDB 5.5. Transactions acquire metadata locks when they access a table or view for the first time. This includes non-transactional tables such as Aria tables. Metadata locks prevent transactions from dropping the locked object or modifying the structure. This is very important because if a transaction is using a table, you want to be sure that the table columns (or even the whole table) will not disappear in the middle. In some cases, stored programs are also locked.
If a connection tries to execute a DDL statement (such as ALTER TABLE
) on a table that has a metadata lock, the connection will be put on hold until the locks are released. However, metadata locks use a timeout, which is defined by the lock_wait_timeout
expressed in seconds. Note that the default value is 31536000
, which corresponds to one year. If the timeout expires, the connection receives a 1205 error.
Since, as we mentioned before...