• Marko Mäkelä's avatar
    MDEV-23998 Race between buf_page_optimistic_get() and buf_page_t::init() · 1668465f
    Marko Mäkelä authored
    MDEV-22871 tried to optimize the buf_page_t initialization in
    buf_page_init_for_read() by initializing everything while the block
    is in freed state, and only afterwards attaching the block to
    buf_pool.page_hash.
    
    In an rr replay trace, we have multiple threads executing in
    buf_page_optimistic_get() on the same buf_block_t while the block is
    being freed and reallocated several times in buf_page_init_for_read().
    Because also the buf_page_t::id() is changing, the buf_pool.page_hash
    is being protected by a different rw-lock than the one that
    buf_page_optimistic_get() are successfully read-locking.
    
    buf_page_optimistic_get(): Validate also buf_page_t::id() after
    acquiring the buf_pool.page_hash latch.
    
    Reviewed by: Thirunarayanan Balathandayuthapani
    1668465f
buf0buf.cc 139 KB