• Jan Lindström's avatar
    MDEV-23536 : Race condition between KILL and transaction commit · 775fccea
    Jan Lindström authored
    A race condition may occur between the execution of transaction commit,
    and an execution of a KILL statement that would attempt to abort that
    transaction.
    
    MDEV-17092 worked around this race condition by modifying InnoDB code.
    After that issue was closed, Sergey Vojtovich pointed out that this
    race condition would better be fixed above the storage engine layer:
    
    If you look carefully into the above, you can conclude that
    thd->free_connection() can be called concurrently with
    KILL/thd->awake(). Which is the bug. And it is partially fixed in
    THD::~THD(), that is destructor waits for KILL completion:
    
    Fix: Add necessary mutex operations to THD::free_connection()
    and move WSREP specific code also there. This ensures that no
    one is using THD while we do free_connection(). These mutexes
    will also ensures that there can't be concurrent KILL/THD::awake().
    
    innobase_kill_query
      We can now remove usage of trx_sys_mutex introduced on MDEV-17092.
    
    trx_t::free()
      Poison trx->state and trx->mysql_thd
    
    This patch is validated with an RQG run similar to the one that
    reproduced MDEV-17092.
    775fccea
lock0lock.cc 198 KB