mariadb/storage/innobase/btr
Alessandro Vetere e151cb583d SAMU-322: avoid spurious AHI params setting
In btr_search_info_update_hash, when hash potential is reset,
make sure that AHI params are properly reset too.

Before this changes, when cmp == 0, this assignment could be done
if cursor.low_match == 0 and cursor.low_bytes == 0:

info.left_bytes_field= 0x80010000;  // 1-byte left prefix

Since the code is not fully thread safe by design, another thread
could have already taken the !n_hash_potential branch before,
and got to where the potential of the hash is increased:

info.n_hash_potential= ++n_hash_potential;

If the reset to 0x80010000 happened right before the hash potential increment,
then an AHI index with 1-byte left prefix could be later (possibly wrongly)
built on the page.

With this change, the assignment in case cmp == 0 becomes the
same that the resetting code applied:

info.left_bytes_field= 0x80000001;  // 1-field left prefix

This is more in-line pre-MDEV-35049 code behavior.

A more coherent albeit possibly more costly solution would be to merge
all the AHI "status" variables into one 64 bits atomic word, so that
by design the above concurrency issues could not be applicable.

Many thanks to Marko Mäkelä <marko.makela@mariadb.com> for spotting the
relevant code and for the collaboration.
2025-09-24 15:39:09 +00:00
..
btr0btr.cc Tag the sql/log.h family with ATTRIBUTE_FORMAT 2025-02-12 10:17:44 +01:00
btr0bulk.cc Merge 10.11 into 11.4 2024-12-02 11:35:34 +02:00
btr0cur.cc MDEV-35049: Always enable page_cur_search_with_match_bytes() 2025-01-10 16:40:37 +02:00
btr0pcur.cc MDEV-35049: Improve btr_search_drop_page_hash_index() 2025-01-10 16:40:34 +02:00
btr0sea.cc SAMU-322: avoid spurious AHI params setting 2025-09-24 15:39:09 +00:00