• Jon Olav Hauglid's avatar
    Bug #54360 Deadlock DROP/ALTER/CREATE DATABASE with open HANDLER · b4593605
    Jon Olav Hauglid authored
    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.
    b4593605
schema.test 1.47 KB