• Marko Mäkelä's avatar
    MDEV-32049 Deadlock due to log_free_check() in trx_purge_truncate_history() · 2db5f1b2
    Marko Mäkelä authored
    The function log_free_check() is not supposed to be invoked while
    the caller is holding any InnoDB synchronization objects, such as
    buffer page latches, tablespace latches, index tree latches, or
    in this case, rseg->mutex (rseg->latch in 10.6 or later).
    
    A hang was reported in 10.6 where several threads were waiting for
    an rseg->latch that had been exclusively acquired in
    trx_purge_truncate_history(), which invoked log_free_check() inside
    trx_purge_truncate_rseg_history(). Because the threads that were
    waiting for the rseg->latch were holding exclusive latches on some
    index pages, log_free_check() was unable to advance the checkpoint
    because those index pages could not be written out.
    
    trx_purge_truncate_history(): Invoke log_free_check() before
    acquiring the rseg->mutex and invoking trx_purge_free_segment().
    
    trx_purge_free_segment(): Do not invoke log_free_check() in order
    to avoid a deadlock.
    2db5f1b2
trx0purge.cc 36.3 KB