• Jon Olav Hauglid's avatar
    Backport of revno: 2617.68.37 · fb6b5ee4
    Jon Olav Hauglid authored
    Bug #46654 False deadlock on concurrent DML/DDL with partitions, 
               inconsistent behavior
    
    The problem was that if one connection is running a multi-statement 
    transaction which involves a single partitioned table, and another 
    connection attempts to alter the table, the first connection gets 
    ER_LOCK_DEADLOCK and cannot proceed anymore, even when the ALTER TABLE 
    statement in another connection has timed out or failed.
    
    The reason for this was that the prepare phase for ALTER TABLE for 
    partitioned tables removed all instances of the table from the table 
    definition cache before it started waiting on the lock. The transaction 
    running in the first connection would notice this and report ER_LOCK_DEADLOCK. 
    
    This patch changes the prep_alter_part_table() ALTER TABLE code so that 
    tdc_remove_table() is no longer called. Instead, only the TABLE instance
    changed by prep_alter_part_table() is marked as needing reopen.
    
    The patch also removes an unnecessary call to tdc_remove_table() from 
    mysql_unpack_partition() as the changed TABLE object is destroyed by the 
    caller at a later point.
    
    Test case added in partition_sync.test.
    fb6b5ee4
sql_table.cc 249 KB