• Jon Olav Hauglid's avatar
    Bug #55930 Assertion `thd->transaction.stmt.is_empty() || · 4eb32469
    Jon Olav Hauglid authored
               thd->in_sub_stmt || (thd->state..
    
    OPTIMIZE TABLE is not directly supported by InnoDB. Instead,
    recreate and analyze of the table is done. After recreate,
    the table is closed and locks are released before the table
    is reopened and locks re-acquired for the analyze phase.
    
    This assertion was triggered if OPTIMIZE TABLE failed to
    acquire thr_lock locks before starting the analyze phase.
    The assertion tests (among other things) that there no
    active statement transaction. However, as part of acquiring
    the thr_lock lock, external_lock() is called for InnoDB
    tables and this causes a statement transaction to be started.
    If thr_multi_lock() later fails (e.g. due to timeout),
    the failure handling code causes this assert to be triggered.
    
    This patch fixes the problem by doing rollback of the
    current statement transaction in case open_ltable (used by
    OPTIMIZE TABLE) fails to acquire thr_lock locks.
    
    Test case added to lock_sync.test.
    4eb32469
lock_sync.test 34.1 KB