• Marko Mäkelä's avatar
    MDEV-29835 InnoDB hang on B-tree split or merge · f2096478
    Marko Mäkelä authored
    This is a follow-up to
    commit de4030e4 (MDEV-30400),
    which fixed some hangs related to B-tree split or merge.
    
    btr_root_block_get(): Use and update the root page guess. This is just
    a minor performance optimization, not affecting correctness.
    
    btr_validate_level(): Remove the parameter "lockout", and always
    acquire an exclusive dict_index_t::lock in CHECK TABLE without QUICK.
    This is needed in order to avoid latching order violation in
    btr_page_get_father_node_ptr_for_validate().
    
    btr_cur_need_opposite_intention(): Return true in case
    btr_cur_compress_recommendation() would hold later during the
    mini-transaction, or if a page underflow or overflow is possible.
    If we return true, our caller will escalate to aqcuiring an exclusive
    dict_index_t::lock, to prevent a latching order violation and deadlock
    during btr_compress() or btr_page_split_and_insert().
    
    btr_cur_t::search_leaf(), btr_cur_t::open_leaf():
    Also invoke btr_cur_need_opposite_intention() on the leaf page.
    
    btr_cur_t::open_leaf(): When escalating to exclusive index locking,
    acquire exclusive latches on all pages as well.
    
    innobase_instant_try(): Return an error code if the root page cannot
    be retrieved.
    
    In addition to the normal stress testing with Random Query Generator (RQG)
    this has been tested with
    ./mtr --mysqld=--loose-innodb-limit-optimistic-insert-debug=2
    but with the injection in btr_cur_optimistic_insert() for non-leaf pages
    adjusted so that it would use the value 3. (Otherwise, infinite page
    splits could occur in some mtr tests.)
    
    Tested by: Matthias Leich
    f2096478
handler0alter.cc 327 KB