mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 12:32:27 +01:00
b4593605e0
This deadlock happened if DROP DATABASE was blocked due to an open HANDLER table from a different connection. While DROP DATABASE is blocked, it holds the LOCK_mysql_create_db mutex. This results in a deadlock if the connection with the open HANDLER table tries to execute a CREATE/ALTER/DROP DATABASE statement as they all try to acquire LOCK_mysql_create_db. This patch makes this deadlock scenario very unlikely by closing and marking for re-open all HANDLER tables for which there are pending conflicing locks, before LOCK_mysql_create_db is acquired. However, there is still a very slight possibility that a connection could access one of these HANDLER tables between closing/marking for re-open and the acquisition of LOCK_mysql_create_db. This patch is for 5.1 only, a separate and complete fix will be made for 5.5+. Test case added to schema.test.
32 lines
714 B
Text
32 lines
714 B
Text
drop database if exists mysqltest1;
|
|
create schema foo;
|
|
show create schema foo;
|
|
Database Create Database
|
|
foo CREATE DATABASE `foo` /*!40100 DEFAULT CHARACTER SET latin1 */
|
|
show schemas;
|
|
Database
|
|
information_schema
|
|
foo
|
|
mtr
|
|
mysql
|
|
test
|
|
drop schema foo;
|
|
#
|
|
# Bug#54360 Deadlock DROP/ALTER/CREATE DATABASE with open HANDLER
|
|
#
|
|
CREATE DATABASE db1;
|
|
CREATE TABLE db1.t1 (a INT);
|
|
INSERT INTO db1.t1 VALUES (1), (2);
|
|
# Connection con1
|
|
HANDLER db1.t1 OPEN;
|
|
# Connection default
|
|
# Sending:
|
|
DROP DATABASE db1;
|
|
# Connection con2
|
|
# Waiting for 'DROP DATABASE db1' to sync in.
|
|
# Connection con1
|
|
CREATE DATABASE db2;
|
|
ALTER DATABASE db2 DEFAULT CHARACTER SET utf8;
|
|
DROP DATABASE db2;
|
|
# Connection default
|
|
# Reaping: DROP DATABASE db1
|