• Marko Mäkelä's avatar
    MDEV-22769 Shutdown hang or crash due to XA breaking locks · efc70da5
    Marko Mäkelä authored
    The background drop table queue in InnoDB is a work-around for
    cases where the SQL layer is requesting DDL on tables on which
    transactional locks exist.
    
    One such case are XA transactions. Our test case exploits the
    fact that the recovery of XA PREPARE transactions will
    only resurrect InnoDB table locks, but not MDL that should
    block any concurrent DDL.
    
    srv_shutdown_t: Introduce the srv_shutdown_state=SRV_SHUTDOWN_INITIATED
    for the initial part of shutdown, to wait for the background drop
    table queue to be emptied.
    
    srv_shutdown_bg_undo_sources(): Assign
    srv_shutdown_state=SRV_SHUTDOWN_INITIATED
    before waiting for the background drop table queue to be emptied.
    
    row_drop_tables_for_mysql_in_background(): On slow shutdown, if
    no active transactions exist (excluding ones that are in
    XA PREPARE state), skip any tables on which locks exist.
    
    row_drop_table_for_mysql(): Do not unnecessarily attempt to
    drop InnoDB persistent statistics for tables that have
    already been added to the background drop table queue.
    
    row_mysql_close(): Relax an assertion, and free all memory
    even if innodb_force_recovery=2 would prevent the background
    drop table queue from being emptied.
    efc70da5
srv0start.cc 80.8 KB