• Marko Mäkelä's avatar
    MDEV-11802 InnoDB purge does not always run when there is work to do · 13dcdb09
    Marko Mäkelä authored
    srv_sys_t::n_threads_active[]: Protect writes by both the mutex and
    by atomic memory access.
    
    srv_active_wake_master_thread_low(): Reliably wake up the master
    thread if there is work to do. The trick is to atomically read
    srv_sys->n_threads_active[].
    
    srv_wake_purge_thread_if_not_active(): Atomically read
    srv_sys->n_threads_active[] (and trx_sys->rseg_history_len),
    so that the purge should always be triggered when there is work to do.
    
    trx_commit_in_memory(): Invoke srv_wake_purge_thread_if_not_active()
    whenever a transaction is committed. Purge could have been prevented by
    the read view of the currently committing transaction, even if it is
    a read-only transaction.
    
    trx_purge_add_update_undo_to_history(): Do not wake up the purge.
    This is only called by trx_undo_update_cleanup(), as part of
    trx_write_serialisation_history(), which in turn is only called by
    trx_commit_low() which will always call trx_commit_in_memory().
    Thus, the added call in trx_commit_in_memory() will cover also
    this use case where a committing read-write transaction added
    some update_undo log to the purge queue.
    
    trx_rseg_mem_restore(): Atomically modify trx_sys->rseg_history_len.
    13dcdb09
srv0srv.cc 90 KB