• Marko Mäkelä's avatar
    MDEV-12091 Shutdown fails to wait for rollback of recovered transactions to finish · e5b155a4
    Marko Mäkelä authored
    In the 10.1 InnoDB Plugin, a call os_event_free(buf_flush_event) was
    misplaced. The event could be triggered by rollback of resurrected
    transactions while shutdown was in progress. This bug was caught
    by cmake -DWITH_ASAN testing. This call was only present in the
    10.1 InnoDB Plugin, not in other versions, or in XtraDB.
    
    That said, the bug affects all InnoDB versions. Shutdown assumes the
    cessation of any page-dirtying activity, including the activity of
    the background rollback thread. InnoDB only waited for the background
    rollback to finish as part of a slow shutdown (innodb_fast_shutdown=0).
    The default is a clean shutdown (innodb_fast_shutdown=1). In a scenario
    where InnoDB is killed, restarted, and shut down soon enough, the data
    files could become corrupted.
    
    logs_empty_and_mark_files_at_shutdown(): Wait for the
    rollback to finish, except if innodb_fast_shutdown=2
    (crash-like shutdown) was requested.
    
    trx_rollback_or_clean_recovered(): Before choosing the next
    recovered transaction to roll back, terminate early if non-slow
    shutdown was initiated. Roll back everything on slow shutdown
    (innodb_fast_shutdown=0).
    
    srv_innodb_monitor_mutex: Declare as static, because the mutex
    is only used within one module.
    
    In 10.2, os_event_destroy() sets the event to a NULL pointer,
    while os_event_free() in earlier versions did not do that.
    e5b155a4
srv0srv.cc 91.1 KB