• Marko Mäkelä's avatar
    MDEV-22877 Avoid unnecessary buf_pool.page_hash S-latch acquisition · d2c593c2
    Marko Mäkelä authored
    MDEV-15053 did not remove all unnecessary buf_pool.page_hash S-latch
    acquisition. There are code paths where we are holding buf_pool.mutex
    (which will sufficiently protect buf_pool.page_hash against changes)
    and unnecessarily acquire the latch. Many invocations of
    buf_page_hash_get_locked() can be replaced with the much simpler
    buf_pool.page_hash_get_low().
    
    In the worst case the thread that is holding buf_pool.mutex will become
    a victim of MDEV-22871, suffering from a spurious reader-reader conflict
    with another thread that genuinely needs to acquire a buf_pool.page_hash
    S-latch.
    
    In many places, we were also evaluating page_id_t::fold() while holding
    buf_pool.mutex. Low-level functions such as buf_pool.page_hash_get_low()
    must get the page_id_t::fold() as a parameter.
    
    buf_buddy_relocate(): Defer the hash_lock acquisition to the critical
    section that starts by calling buf_page_t::can_relocate().
    d2c593c2
log0recv.cc 108 KB