• Jon Olav Hauglid's avatar
    Backport of revno: 2617.76.2 · 05a126ed
    Jon Olav Hauglid authored
    Bug #47107 assert in notify_shared_lock on incorrect CREATE TABLE , HANDLER
    
    Attempts to create a table (using CREATE TABLE, CREATE TABLE LIKE or
    CREATE TABLE SELECT statements) which already existed and was opened
    by the same connection through HANDLER statement, led to a stalled
    connection (for production builds of the server) or to the server being
    aborted due to an assertion failure (for debug builds of the server).
    
    This problem was introduced by the new implementation of a metadata
    locking subsystem and didn't affect earlier versions of the server.
    
    The cause of the problem was that the HANDLER was not closed by CREATE TABLE
    before CREATE tried to open and lock the table. Acquiring an exclusive MDL
    lock on the table to be created would therefore fail since HANDLER
    already had a shared MDL lock. This triggered an assert as the 
    HANDLER and CREATE statements came from the same thread (self-deadlock).
    
    This patch resolves the issue by closing any open HANDLERs on tables
    to be created by CREATE TABLE, similar to what is already done for 
    DROP and ALTER TABLE.
    
    Test case added to create.test.
    05a126ed
create.result 108 KB