• Marko Mäkelä's avatar
    MDEV-24789: Reduce lock_sys mutex contention further · 8d16da14
    Marko Mäkelä authored
    lock_sys_t::deadlock_check(): Assume that only lock_sys.wait_mutex
    is being held by the caller.
    
    lock_sys_t::rd_lock_try(): New function.
    
    lock_sys_t::cancel(trx_t*): Kill an active transaction that may be
    holding a lock.
    
    lock_sys_t::cancel(trx_t*, lock_t*): Cancel a waiting lock request.
    
    lock_trx_handle_wait(): Avoid acquiring mutexes in some cases,
    and in never acquire lock_sys.latch in exclusive mode.
    This function is only invoked in a semi-consistent read
    (locking a clustered index record only if it matches the search condition).
    Normally, lock_wait() will take care of lock waits.
    
    lock_wait(): Invoke the new function lock_sys_t::cancel() at the end,
    to avoid acquiring exclusive lock_sys.latch.
    
    lock_rec_other_trx_holds_expl(): Use LockGuard instead of LockMutexGuard.
    
    lock_release_autoinc_locks(): Explicitly acquire table->lock_mutex,
    in case only a shared lock_sys.latch is being held. Deadlock::report()
    will still hold exclusive lock_sys.latch while invoking
    lock_cancel_waiting_and_release().
    
    lock_cancel_waiting_and_release(): Acquire trx->mutex in this function,
    instead of expecting the caller to do so.
    
    lock_unlock_table_autoinc(): Only acquire shared lock_sys.latch.
    
    lock_table_has_locks(): Do not acquire lock_sys.latch at all.
    
    Deadlock::check_and_resolve(): Only acquire shared lock_sys.latchm
    for invoking lock_sys_t::cancel(trx, wait_lock).
    
    innobase_query_caching_table_check_low(),
    row_drop_tables_for_mysql_in_background(): Do not acquire lock_sys.latch.
    8d16da14
ha_innodb.cc 593 KB