• Marko Mäkelä's avatar
    MDEV-30148 Race condition between non-persistent statistics and purge · 0a7d85c9
    Marko Mäkelä authored
    btr_cur_t::open_random_leaf(): Replaces btr_cur_open_at_rnd_pos().
    Acquire a shared latch on each page, and finally release all
    latches except the one on the leaf page.
    
    This fixes a race condition between the purge of history and
    btr_estimate_number_of_different_key_vals(), which turned out
    to only hold a buffer-fix on the randomly chosen leaf page.
    Typically, an assertion would fail in page_rec_is_supremum().
    
    ibuf_contract(): Start from the beginning of the change buffer,
    to simplify the logic. Starting with
    commit b42294bc
    it does not matter much where the change buffer merge is being initiated.
    
    The race condition may have been introduced as early as
    mysql/mysql-server@ac74632293bea967b352d1b472abedeeaa921b98
    from where it was copied to
    commit 2e814d47.
    
    Reviewed by: Vladislav Lesin
    Tested by: Matthias Leich
    0a7d85c9
dict0stats.cc 137 KB