You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MDEV-37482: Contention on btr_sea::partition::latch
To reduce contention between insert, erase and search, let us mimic
commit b08448d (MDEV-20612).
That is, btr_sea::partition::insert() and btr_sea::partition::erase()
will use a combination of a shared btr_sea::partition::latch and a
tiny page_hash_latch that is pushed down to the btr_sea::hash_table::array.
An exclusive btr_sea::partition::latch will be used in the final part of
btr_search_drop_page_hash_index(), where we must guarantee that all
entries will be removed, as well as in operations that affect an entire
adaptive hash index partition.
btr_sea::hash_chain: Chain of ahi_node hash buckets.
btr_sea::hash_table: A hash table that includes page_hash_latch
interleaved with hash_chain.
page_hash_latch::try_lock(): Attempt to acquire an exclusive latch
without waiting.
btr_search_guess_on_hash(): Acquire also the page_hash_latch in order
to prevent a concurrent modification of the hash bucket chain that our
lookup is traversing.
ha_insert_for_fold(): Remove. Invoke btr_sea::partition::insert() directly.
btr_sea::partition::erase(): Add template<bool ex> for indicating whether
an exclusive or a shared btr_sea::partition::latch is being held.
If the ex=false operation fails to free the memory,
btr_search_update_hash_on_delete() will retry with ex=true.
btr_sea::partition::cleanup_after_erase(): Add an overload for the case
where instead of holding an exclusive latch, we hold a shared latch
along with a page_hash_latch. When not holding an exclusve latch,
we may fail to free the memory, and the caller has to retry with an
exclusive latch.
btr_sea::partition::cleanup_after_erase_start(),
btr_sea::partition::cleanup_after_erase_finish(): Split from
cleanup_after_erase() to reduce the amount of code duplication.
btr_sea::partition::block_mutex: Protect only the linked list of blocks.
The spare block will exclusively be updated via Atomic_relaxed::exchange().
btr_sea::partition::rollback_insert(): Free the spare block in the unlikely
event that the adaptive hash index has been disabled after our invocation
of btr_sea::partition::prepare_insert().
ha_remove_all_nodes_to_page(): Merged to the only caller
btr_search_drop_page_hash_index().
ssux_lock_impl::wr_rd_downgrade(): Downgrade an X latch to S.
srw_lock_debug::wr_rd_downgrade(), srw_lock_impl::wr_rd_downgrade():
Downgrade from exclusive to shared. This operation is unavailable
if _WIN32 or SUX_LOCK_GENERIC is defined.
btr_search_build_page_hash_index(): Downgrade from exclusive to shared
part.latch before starting to insert records into the adaptive hash index.
In multi-batch operation, we preserve the last fr[] value in order to
ensure the correct operation when buf_block_t::LEFT_SIDE is not set.
0 commit comments