• Marko Mäkelä's avatar
    MDEV-29883 Deadlock between InnoDB statistics update and BLOB insert · 6b91792a
    Marko Mäkelä authored
    This is a backport of commit 8b6a308e
    from MariaDB Server 10.6.11. No attempt to reproduce the hang
    in earlier an earlier version of MariaDB Server than 10.6 was made.
    
    In each caller of fseg_n_reserved_pages() except ibuf_init_at_db_start()
    which is a special case for ibuf.index at database startup, we must hold
    an index latch that prevents concurrent allocation or freeing of index
    pages.
    
    Any operation that allocates or free pages that belong to an index tree
    must first acquire an index latch in non-shared mode, and while
    holding that, acquire an index root page latch in non-shared mode.
    
    btr_get_size(), btr_get_size_and_reserved(): Assert that a strong enough
    index latch is being held.
    
    dict_stats_update_transient_for_index(),
    dict_stats_analyze_index(): Acquire a strong enough index latch.
    
    These operations had followed the same order of acquiring latches in
    every InnoDB version since the very beginning
    (commit c533308a).
    
    The hang was introduced in
    commit 2e814d47 which imported
    mysql/mysql-server@ac74632293bea967b352d1b472abedeeaa921b98
    which failed to strengthen the locking requirements of the function
    btr_get_size().
    6b91792a
dict0defrag_bg.cc 8.82 KB