• Sergei Golubchik's avatar
    MDEV-16465 Invalid (old?) table or database name or hang in... · 9180e866
    Sergei Golubchik authored
    MDEV-16465 Invalid (old?) table or database name or hang in ha_innobase::delete_table and log semaphore wait upon concurrent DDL with foreign keys
    
    ALTER TABLE locks the table with TL_READ_NO_INSERT, to prevent the
    source table modifications while it's being copied. But there's an
    indirect way of modifying a table, via cascade FK actions.
    
    After previous commits, an attempt to modify an FK parent table
    will cause FK children to be prelocked, so the table-being-altered
    cannot be modified by a cascade FK action, because ALTER holds a
    lock and prelocking will wait.
    
    But if a new FK is being added by this very ALTER, then the target
    table is not locked yet (it's a temporary table). So, we have to
    lock FK parents explicitly.
    9180e866
foreign-keys.test 3.65 KB