• Aleksey Midenkov's avatar
    MDEV-29544 SIGSEGV in HA_CREATE_INFO::finalize_locked_tables · dcd66c38
    Aleksey Midenkov authored
    Usually when we get into finalize_locked_tables() with error
    m_locked_tables_count was not decremented. m_locked_tables_count is
    decremented when we drop the original table and if we failed that
    m_locked_tables_count is expected intact.
    
    The bug comes from the fact that finalize_atomic_replace() violates
    the above contract. It does HA_EXTRA_PREPARE_FOR_DROP and decrements
    m_locked_tables_count. Then it tries rename_table_and_triggers() and
    fails. With decremented m_locked_tables_count reopen_tables() does
    nothing and we don't get new value for pos_in_locked_tables->table.
    
    The test case demonstrates ER_ERROR_ON_RENAME where non-atomic CREATE
    OR REPLACE would not fail. The original RENAME TABLE fails under such
    broken environment, so nothing is wrong with atomic CREATE OR REPLACE
    failing there too.
    dcd66c38
create_or_replace.test 19.3 KB