• Marko Mäkelä's avatar
    MDEV-26033: Race condition between buf_pool.page_hash and resize() · bd5a6403
    Marko Mäkelä authored
    The replacement of buf_pool.page_hash with a different type of
    hash table in commit 5155a300 (MDEV-22871)
    introduced a race condition with buffer pool resizing.
    
    We have an execution trace where buf_pool.page_hash.array is changed
    to point to something else while page_hash_latch::read_lock() is
    executing. The same should also affect page_hash_latch::write_lock().
    
    We fix the race condition by never resizing (and reallocating) the
    buf_pool.page_hash. We assume that resizing the buffer pool is
    a rare operation. Yes, there might be a performance regression if a
    server is first started up with a tiny buffer pool, which is later
    enlarged. In that case, the tiny buf_pool.page_hash.array could cause
    increased use of the hash bucket lists. That problem can be worked
    around by initially starting up the server with a larger buffer pool
    and then shrinking that, until changing to a larger size again.
    
    buf_pool_t::resize_hash(): Remove.
    
    buf_pool_t::page_hash_table::lock(): Do not attempt to deal with
    hash table resizing. If we really wanted that in a safe manner,
    we would probably have to introduce a global rw-lock around the
    operation, or at the very least, poll buf_pool.resizing, both of
    which would be detrimental to performance.
    bd5a6403
buf0buf.h 80 KB