summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThirunarayanan Balathandayuthapani <thiru@mariadb.com>2022-11-17 11:59:06 +0530
committerThirunarayanan Balathandayuthapani <thiru@mariadb.com>2022-11-21 12:26:26 +0530
commit7fea90e30a6a9d3fc8f3dd39139cb10cbcdc685b (patch)
tree40c4c6525006a0b49a9085198f937fcd1be2e292
parent6b083ce85185b2362e212c5e5a2a1ddc4acfcc68 (diff)
downloadmariadb-git-bb-10.6-MDEV-28462.tar.gz
MDEV-28462 Race condition between instant alter and AHI accessbb-10.6-MDEV-28462
- InnoDB AHI tries to access the concurrent instant alter column, leads to asan failure. Instant alter column should acquire the clustered index search latch in exclusive mode before changing the table cache definition.
-rw-r--r--storage/innobase/handler/handler0alter.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index fbb640e7c62..35d37def5cf 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -5847,7 +5847,12 @@ static bool innobase_instant_try(
const dict_col_t* old_cols = user_table->cols;
DBUG_ASSERT(user_table->n_cols == ctx->old_n_cols);
+ /* Acquire the ahi latch to avoid the race condition
+ between ahi access and instant alter table */
+ srw_spin_lock *ahi_latch = btr_search_sys.get_latch(*index);
+ ahi_latch->wr_lock(SRW_LOCK_CALL);
const bool metadata_changed = ctx->instant_column();
+ ahi_latch->wr_unlock();
DBUG_ASSERT(index->n_fields >= n_old_fields);
/* The table may have been emptied and may have lost its