Description:
The test case is similar to bug#54360, only with LOCK TABLE instead of OPEN HANDLER, and CREATE instead of ALTER database.
One connection locks a table in a schema, another connection attempts to drop the schema and starts waiting, then the first connection attempts to create another database and instead creates a deadlock.
Reproducible on 5.1.49, not reproducible on 5.5.
How to repeat:
# Test case
CREATE DATABASE db1;
CREATE TABLE db1.t1 (a INT);
--connect (con1, localhost, root)
LOCK TABLE db1.t1 WRITE;
--connection default
--send DROP DATABASE db1
--connection con1
--sleep 1
CREATE DATABASE db2;
--connection default
# We don't reach this
--reap
--exit
Suggested fix:
The problem is not reproducible with DROP or ALTER database instead of the last CREATE, because both DROP and ALTER immediately fail with ER_LOCK_OR_ACTIVE_TRANSACTION. Possibly it should also be the case for CREATE? In 5.5 it is the same for all of CREATE/ALTER/DROP DATABASE.