• Marko Mäkelä's avatar
    MDEV-30357 Performance regression in locking reads from secondary indexes · 4105017a
    Marko Mäkelä authored
    lock_sec_rec_some_has_impl(): Remove a harmful condition that caused the
    performance regression and should not have been added in
    commit b6e41e38 in the first place.
    Locking transactions that have not modified any persistent tables
    can carry the transaction identifier 0.
    
    trx_t::max_inactive_id: A cache for trx_sys_t::find_same_or_older().
    The value is not reset on transaction commit so that previous results
    can be reused for subsequent transactions. The smallest active
    transaction ID can only increase over time, not decrease.
    
    trx_sys_t::find_same_or_older(): Remember the maximum previous id for which
    rw_trx_hash.iterate() returned false, to avoid redundant iterations.
    
    lock_sec_rec_read_check_and_lock(): Add an early return in case we are
    already holding a covering table lock.
    
    lock_rec_convert_impl_to_expl(): Add a template parameter to avoid
    a redundant run-time check on whether the index is secondary.
    
    lock_rec_convert_impl_to_expl_for_trx(): Move some code from
    lock_rec_convert_impl_to_expl(), to reduce code duplication due
    to the added template parameter.
    
    Reviewed by: Vladislav Lesin
    Tested by: Matthias Leich
    4105017a
trx0trx.h 40.4 KB