Skip to content

Commit f4f00e7

Browse files
MDEV-23966 btr_search_sys->hash_tables accessed without taking proper ahi latch
This issue is caused by the commit af40a2b. In btr_search_update_hash_on_insert(), btr_search_sys->hash_tables is being accessed without taking proper ahi latch. During buffer pool resizing, btr_get_search_table() is being accessed and it leads to segmentation fault. Reviewed-by: Marko Mäkelä
1 parent 923ecbd commit f4f00e7

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

storage/innobase/btr/btr0sea.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1797,7 +1797,8 @@ btr_search_update_hash_on_insert(btr_cur_t* cursor)
17971797
}
17981798

17991799
rw_lock_t* const latch = btr_get_search_latch(index);
1800-
hash_table_t* const table = btr_get_search_table(index);
1800+
/* We must not look up "table" before acquiring the latch. */
1801+
hash_table_t* table = NULL;
18011802
bool locked = false;
18021803

18031804
if (!page_rec_is_infimum(rec)) {
@@ -1814,6 +1815,7 @@ btr_search_update_hash_on_insert(btr_cur_t* cursor)
18141815
goto function_exit;
18151816
}
18161817

1818+
table = btr_get_search_table(index);
18171819
ha_insert_for_fold(table, ins_fold, block, ins_rec);
18181820
}
18191821

@@ -1829,6 +1831,8 @@ btr_search_update_hash_on_insert(btr_cur_t* cursor)
18291831
if (!btr_search_enabled || !block->index) {
18301832
goto function_exit;
18311833
}
1834+
1835+
table = btr_get_search_table(index);
18321836
}
18331837

18341838
if (!left_side) {
@@ -1849,6 +1853,8 @@ btr_search_update_hash_on_insert(btr_cur_t* cursor)
18491853
if (!btr_search_enabled || !block->index) {
18501854
goto function_exit;
18511855
}
1856+
1857+
table = btr_get_search_table(index);
18521858
}
18531859

18541860
ha_insert_for_fold(table, ins_fold, block, ins_rec);
@@ -1865,6 +1871,8 @@ btr_search_update_hash_on_insert(btr_cur_t* cursor)
18651871
if (!btr_search_enabled || !block->index) {
18661872
goto function_exit;
18671873
}
1874+
1875+
table = btr_get_search_table(index);
18681876
}
18691877

18701878
if (!left_side) {

0 commit comments

Comments
 (0)