Skip to content

Commit 1f24c5a

Browse files
author
Aditya A
committed
Bug #27208858 CONCURRENT DDL/DML ON FOREIGN KEYS CRASH IN PAGE_CUR_SEARCH_WITH_MATCH_BYTES
PROBLEM ------- 1. During truncate when we are trying to flush out the pages of truncated table form the buffer pool we release the dict lock. 2. At this stage a DDL request to add a FK constraint from another connection,tries to access the stale index memory object of the parent table and asserts. FIX --- Disallow the DDL operation of adding FK when parent table is undergoing truncate . [#rb 19433 Reviewed by Jimmy ]
1 parent 484e719 commit 1f24c5a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

storage/innobase/fil/fil0fil.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2997,6 +2997,7 @@ fil_reinit_space_header_for_table(
29972997
they won't violate the latch ordering. */
29982998
dict_table_x_unlock_indexes(table);
29992999
row_mysql_unlock_data_dictionary(trx);
3000+
DEBUG_SYNC_C("trunc_table_index_dropped_release_dict_lock");
30003001

30013002
/* Lock the search latch in shared mode to prevent user
30023003
from disabling AHI during the scan */

storage/innobase/row/row0ins.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,7 +1618,8 @@ row_ins_check_foreign_constraint(
16181618

16191619
if (check_table == NULL
16201620
|| check_table->ibd_file_missing
1621-
|| check_index == NULL) {
1621+
|| check_index == NULL
1622+
|| fil_space_is_being_truncated(check_table->space)) {
16221623

16231624
if (!srv_read_only_mode && check_ref) {
16241625
FILE* ef = dict_foreign_err_file;
@@ -1640,7 +1641,8 @@ row_ins_check_foreign_constraint(
16401641
ut_print_name(ef, trx,
16411642
foreign->referenced_table_name);
16421643
fputs("\nor its .ibd file does"
1643-
" not currently exist!\n", ef);
1644+
" not currently exist!, or"
1645+
" is undergoing truncate!\n", ef);
16441646
mutex_exit(&dict_foreign_err_mutex);
16451647

16461648
err = DB_NO_REFERENCED_ROW;
@@ -1873,6 +1875,7 @@ row_ins_check_foreign_constraint(
18731875
mem_heap_free(heap);
18741876
}
18751877

1878+
DEBUG_SYNC_C("finished_scanning_index");
18761879
DBUG_RETURN(err);
18771880
}
18781881

0 commit comments

Comments
 (0)