diff --git a/storage/innobase/btr/btr0sea.cc b/storage/innobase/btr/btr0sea.cc index 085ec33..666d351 100644 --- a/storage/innobase/btr/btr0sea.cc +++ b/storage/innobase/btr/btr0sea.cc @@ -734,6 +734,16 @@ btr_search_info_update_slow( build_index = btr_search_update_block_hash_info(info, block, cursor); + /** If the AHI partition latch is currently X-locked by another writer, + * we avoid contending on this latch as this function is on the critical + * btree search path. + * Since we do not clear any search stats on this block, the hash index + * will eventually be built when accessing this page later again. */ + if (build_index && rw_lock_get_writer(btr_get_search_latch(cursor->index)) + != RW_LOCK_NOT_LOCKED) { + return; + } + if (build_index || (cursor->flag == BTR_CUR_HASH_FAIL)) { btr_search_check_free_space_in_heap(cursor->index);