diff options
author | Thirunarayanan Balathandayuthapani <thiru@mariadb.com> | 2022-11-17 17:24:13 +0530 |
---|---|---|
committer | Thirunarayanan Balathandayuthapani <thiru@mariadb.com> | 2022-11-17 17:24:32 +0530 |
commit | 7315b7103da5fc9b942caf1f39a568d4ad3366df (patch) | |
tree | a806099dcd89b1d9682c7adca258718f083a1226 | |
parent | df4c3d96a4aba0e5a9af3bd5158cd2049a978130 (diff) | |
download | mariadb-git-bb-10.3-MDEV-28462.tar.gz |
MDEV-28462 Race condition between instant alter and AHI accessbb-10.3-MDEV-28462
- InnoDB AHI tries to access the concurrent instant alter column,
leads to asan failure. Instant alter column should acquire all
search latches in shared mode before changing the table cache
definition.
-rw-r--r-- | storage/innobase/handler/handler0alter.cc | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 0cba7d953d1..39f0e4d82aa 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -4371,8 +4371,14 @@ innobase_add_instant_try( DBUG_ASSERT(ctx->old_table->n_cols == ctx->old_n_cols); dict_table_t* user_table = ctx->old_table; - user_table->instant_add_column(*ctx->instant_table); dict_index_t* index = dict_table_get_first_index(user_table); + + /* Acquire the ahi latch to avoid the race condition + between ahi access and instant alter table */ + rw_lock_t* ahi_latch = btr_get_search_latch(index); + rw_lock_x_lock(ahi_latch); + user_table->instant_add_column(*ctx->instant_table); + rw_lock_x_unlock(ahi_latch); /* The table may have been emptied and may have lost its 'instant-add-ness' during this instant ADD COLUMN. */ |