Skip to content

Commit 9ce1ea6

Browse files
Shaohua Wangdr-m
authored andcommitted
BUG#24009272 SEGFAULT WITH CREATE+SELECT FROM IS+DROP FTS TABLE CONCURRENTLY
Analysis: When we access fts_internal_tbl_name in i_s_fts_config_fill (), it can be set to NULL by another session. Solution: Define fts_internal_tbl_name2 for global variable innodb_ft_aux_table, if it's NULL, set fts_internal_tbl_name to "default". Reviewed-by: Jimmy Yang <jimmy.yang@oracle.com> RB: 13401
1 parent 4b5a9d8 commit 9ce1ea6

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed

storage/innobase/fts/fts0fts.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ static const ulint FTS_DEADLOCK_RETRY_WAIT = 100000;
9393
/** variable to record innodb_fts_internal_tbl_name for information
9494
schema table INNODB_FTS_INSERTED etc. */
9595
char* fts_internal_tbl_name = NULL;
96+
char* fts_internal_tbl_name2 = NULL;
9697

9798
/** InnoDB default stopword list:
9899
There are different versions of stopwords, the stop words listed

storage/innobase/handler/ha_innodb.cc

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18773,6 +18773,41 @@ innodb_internal_table_validate(
1877318773
}
1877418774

1877518775
#ifdef BTR_CUR_HASH_ADAPT
18776+
/****************************************************************//**
18777+
Update global variable "fts_internal_tbl_name" with the "saved"
18778+
stopword table name value. This function is registered as a callback
18779+
with MySQL. */
18780+
static
18781+
void
18782+
innodb_internal_table_update(
18783+
/*=========================*/
18784+
THD* thd, /*!< in: thread handle */
18785+
struct st_mysql_sys_var* var, /*!< in: pointer to
18786+
system variable */
18787+
void* var_ptr,/*!< out: where the
18788+
formal string goes */
18789+
const void* save) /*!< in: immediate result
18790+
from check function */
18791+
{
18792+
const char* table_name;
18793+
char* old;
18794+
18795+
ut_a(save != NULL);
18796+
ut_a(var_ptr != NULL);
18797+
18798+
table_name = *static_cast<const char*const*>(save);
18799+
old = *(char**) var_ptr;
18800+
*(char**) var_ptr = table_name ? my_strdup(table_name, MYF(0)) : NULL;
18801+
my_free(old);
18802+
18803+
fts_internal_tbl_name2 = *(char**) var_ptr;
18804+
if (fts_internal_tbl_name2 == NULL) {
18805+
fts_internal_tbl_name = const_cast<char*>("default");
18806+
} else {
18807+
fts_internal_tbl_name = fts_internal_tbl_name2;
18808+
}
18809+
}
18810+
1877618811
/****************************************************************//**
1877718812
Update the system variable innodb_adaptive_hash_index using the "saved"
1877818813
value. This function is registered as a callback with MySQL. */
@@ -21226,11 +21261,11 @@ static MYSQL_SYSVAR_BOOL(disable_sort_file_cache, srv_disable_sort_file_cache,
2122621261
"Whether to disable OS system file cache for sort I/O",
2122721262
NULL, NULL, FALSE);
2122821263

21229-
static MYSQL_SYSVAR_STR(ft_aux_table, fts_internal_tbl_name,
21230-
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC,
21264+
static MYSQL_SYSVAR_STR(ft_aux_table, fts_internal_tbl_name2,
21265+
PLUGIN_VAR_RQCMDARG,
2123121266
"FTS internal auxiliary table to be checked",
2123221267
innodb_internal_table_validate,
21233-
NULL, NULL);
21268+
innodb_internal_table_update, NULL);
2123421269

2123521270
static MYSQL_SYSVAR_ULONG(ft_cache_size, fts_max_cache_size,
2123621271
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,

storage/innobase/handler/i_s.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3955,6 +3955,8 @@ i_s_fts_config_fill(
39553955
DBUG_RETURN(0);
39563956
}
39573957

3958+
DEBUG_SYNC_C("i_s_fts_config_fille_check");
3959+
39583960
fields = table->field;
39593961

39603962
/* Prevent DDL to drop fts aux tables. */

storage/innobase/include/fts0fts.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ extern bool fts_need_sync;
409409
/** Variable specifying the table that has Fulltext index to display its
410410
content through information schema table */
411411
extern char* fts_internal_tbl_name;
412+
extern char* fts_internal_tbl_name2;
412413

413414
#definefts_que_graph_free(graph) \
414415
do { \

0 commit comments

Comments
 (0)