• davi@moksha.local's avatar
    Bug#31409 RENAME TABLE causes server crash or deadlock when used with HANDLER statements · 7252cbe1
    davi@moksha.local authored
    This deadlock occurs when a client issues a HANDLER ... OPEN statement
    that tries to open a table that has a pending name-lock on it by another
    client that also needs a name-lock on some other table which is already
    open and associated to a HANDLER instance owned by the first client.
    The deadlock happens because the open_table() function will back-off
    and wait until the name-lock goes away, causing a circular wait if some
    other name-lock is also pending for one of the open HANDLER tables.
    
    Such situation, for example, can be easily repeated by issuing a RENAME
    TABLE command in such a way that the existing table is already open
    as a HANDLER table by another client and this client tries to open
    a HANDLER to the new table name.
    
    The solution is to allow handler tables with older versions (marked for
    flush) to be closed before waiting for the name-lock completion. This is
    safe because no other name-lock can be issued between the flush and the
    check for pending name-locks.
    
    The test case for this bug is going to be committed into 5.1 because it
    requires a test feature only avaiable in 5.1 (wait_condition).
    7252cbe1
sql_base.cc 195 KB