• Sergey Vojtovich's avatar
    MDEV-14410 - Assertion `table->pos_in_locked_tables == __null || · 327b2717
    Sergey Vojtovich authored
                 table->pos_in_locked_tables->table == table'
                 failed in mark_used_tables_as_free_for_reuse
    
    Assertion failure can be triggered by some DDL executed under LOCK TABLES
    that holds lock for DDL target table multiple times (either explicitly or
    implcitly).
    
    When closing all table instances for given table (e.g. when preparing for
    table removal during CREATE OR REPLACE), only one instance was removed
    from m_locked_tables list.
    
    Later we attempt to re-insert one of the instances in mysql_create_table()/
    add_back_last_deleted_lock(), which wasn't actually removed. This leads
    to m_locks_tables corruption, specifically loss of all following elements.
    
    Then UNLOCK TABLE won't reset some table instances properly (specifically
    pos_in_locked_tables), since they're not present in m_locked_tables.
    
    Eventually such table instance gets released to table cache and then
    re-used by subsequent statement, which triggers this assertion failure.
    327b2717
sql_base.cc 313 KB