MDEV-18867 Long Time to Stop and Start

fts_drop_orphaned_tables() takes long time to remove the orphaned
FTS tables. In order to reduce the time, do the following:

- Traverse fil_system.space_list and construct a set of
table_id,index_id of all FTS_*.ibd tablespaces.
- Traverse the sys_indexes table and ignore the entry
from the above collection if it exist.
- Existing elements in the collection can be considered as
orphaned fts tables. construct the table name from
(table_id,index_id) and invoke fts_drop_tables().
- Removed DICT_TF2_FTS_AUX_HEX_NAME flag usage from upgrade.
- is_aux_table() in dict_table_t to check whether the given name
is fts auxiliary table
fts_space_set_t is a structure to store set of parent table id
and index id
- Remove unused FTS function in fts0fts.cc
- Remove the fulltext index in row_format_redundant test case.
Because it deals with the condition that SYS_TABLES does have
corrupted entry and valid entry exist in SYS_INDEXES.
parent 5c07ce40
...@@ -5,8 +5,7 @@ SET GLOBAL innodb_file_per_table=1; ...@@ -5,8 +5,7 @@ SET GLOBAL innodb_file_per_table=1;
# #
SET GLOBAL innodb_file_per_table=ON; SET GLOBAL innodb_file_per_table=ON;
create table t1 (a int not null, d varchar(15) not null, b create table t1 (a int not null, d varchar(15) not null, b
varchar(198) not null, c char(156), varchar(198) not null, c char(156)) engine=InnoDB
fulltext ftsic(c)) engine=InnoDB
row_format=redundant; row_format=redundant;
insert into t1 values(123, 'abcdef', 'jghikl', 'mnop'); insert into t1 values(123, 'abcdef', 'jghikl', 'mnop');
insert into t1 values(456, 'abcdef', 'jghikl', 'mnop'); insert into t1 values(456, 'abcdef', 'jghikl', 'mnop');
...@@ -72,7 +71,7 @@ DROP TABLE t1; ...@@ -72,7 +71,7 @@ DROP TABLE t1;
Warnings: Warnings:
Warning 1932 Table 'test.t1' doesn't exist in engine Warning 1932 Table 'test.t1' doesn't exist in engine
DROP TABLE t2,t3; DROP TABLE t2,t3;
FOUND 50 /\[ERROR\] InnoDB: Table `test`\.`t1` in InnoDB data dictionary contains invalid flags\. SYS_TABLES\.TYPE=1 SYS_TABLES\.MIX_LEN=255\b/ in mysqld.1.err FOUND 6 /\[ERROR\] InnoDB: Table `test`\.`t1` in InnoDB data dictionary contains invalid flags\. SYS_TABLES\.TYPE=1 SYS_TABLES\.MIX_LEN=255\b/ in mysqld.1.err
ib_buffer_pool ib_buffer_pool
ib_logfile0 ib_logfile0
ib_logfile1 ib_logfile1
......
...@@ -32,8 +32,7 @@ SET GLOBAL innodb_file_per_table=1; ...@@ -32,8 +32,7 @@ SET GLOBAL innodb_file_per_table=1;
SET GLOBAL innodb_file_per_table=ON; SET GLOBAL innodb_file_per_table=ON;
create table t1 (a int not null, d varchar(15) not null, b create table t1 (a int not null, d varchar(15) not null, b
varchar(198) not null, c char(156), varchar(198) not null, c char(156)) engine=InnoDB
fulltext ftsic(c)) engine=InnoDB
row_format=redundant; row_format=redundant;
insert into t1 values(123, 'abcdef', 'jghikl', 'mnop'); insert into t1 values(123, 'abcdef', 'jghikl', 'mnop');
......
...@@ -5416,51 +5416,6 @@ fil_delete_file( ...@@ -5416,51 +5416,6 @@ fil_delete_file(
} }
} }
/**
Iterate over all the spaces in the space list and fetch the
tablespace names. It will return a copy of the name that must be
freed by the caller using: delete[].
@return DB_SUCCESS if all OK. */
dberr_t
fil_get_space_names(
/*================*/
space_name_list_t& space_name_list)
/*!< in/out: List to append to */
{
fil_space_t* space;
dberr_t err = DB_SUCCESS;
mutex_enter(&fil_system->mutex);
for (space = UT_LIST_GET_FIRST(fil_system->space_list);
space != NULL;
space = UT_LIST_GET_NEXT(space_list, space)) {
if (space->purpose == FIL_TYPE_TABLESPACE) {
ulint len;
char* name;
len = ::strlen(space->name);
name = UT_NEW_ARRAY_NOKEY(char, len + 1);
if (name == 0) {
/* Caller to free elements allocated so far. */
err = DB_OUT_OF_MEMORY;
break;
}
memcpy(name, space->name, len);
name[len] = 0;
space_name_list.push_back(name);
}
}
mutex_exit(&fil_system->mutex);
return(err);
}
/** Generate redo log for swapping two .ibd files /** Generate redo log for swapping two .ibd files
@param[in] old_table old table @param[in] old_table old table
@param[in] new_table new table @param[in] new_table new table
......
...@@ -148,9 +148,7 @@ fts_config_create_index_param_name( ...@@ -148,9 +148,7 @@ fts_config_create_index_param_name(
::strcpy(name, param); ::strcpy(name, param);
name[len] = '_'; name[len] = '_';
fts_write_object_id(index->id, name + len + 1, fts_write_object_id(index->id, name + len + 1);
DICT_TF2_FLAG_IS_SET(index->table,
DICT_TF2_FTS_AUX_HEX_NAME));
return(name); return(name);
} }
......
This diff is collapsed.
...@@ -55,28 +55,23 @@ fts_get_table_id( ...@@ -55,28 +55,23 @@ fts_get_table_id(
long */ long */
{ {
int len; int len;
bool hex_name = DICT_TF2_FLAG_IS_SET(fts_table->table,
DICT_TF2_FTS_AUX_HEX_NAME);
ut_a(fts_table->table != NULL); ut_a(fts_table->table != NULL);
switch (fts_table->type) { switch (fts_table->type) {
case FTS_COMMON_TABLE: case FTS_COMMON_TABLE:
len = fts_write_object_id(fts_table->table_id, table_id, len = fts_write_object_id(fts_table->table_id, table_id);
hex_name);
break; break;
case FTS_INDEX_TABLE: case FTS_INDEX_TABLE:
len = fts_write_object_id(fts_table->table_id, table_id, len = fts_write_object_id(fts_table->table_id, table_id);
hex_name);
table_id[len] = '_'; table_id[len] = '_';
++len; ++len;
table_id += len; table_id += len;
len += fts_write_object_id(fts_table->index_id, table_id, len += fts_write_object_id(fts_table->index_id, table_id);
hex_name);
break; break;
default: default:
......
...@@ -1349,18 +1349,6 @@ ulint ...@@ -1349,18 +1349,6 @@ ulint
fil_space_get_id_by_name( fil_space_get_id_by_name(
const char* tablespace); const char* tablespace);
/**
Iterate over all the spaces in the space list and fetch the
tablespace names. It will return a copy of the name that must be
freed by the caller using: delete[].
@return DB_SUCCESS if all OK. */
dberr_t
fil_get_space_names(
/*================*/
space_name_list_t& space_name_list)
/*!< in/out: Vector for collecting the names. */
MY_ATTRIBUTE((warn_unused_result));
/** Generate redo log for swapping two .ibd files /** Generate redo log for swapping two .ibd files
@param[in] old_table old table @param[in] old_table old table
@param[in] new_table new table @param[in] new_table new table
......
...@@ -735,12 +735,9 @@ fts_savepoint_rollback_last_stmt( ...@@ -735,12 +735,9 @@ fts_savepoint_rollback_last_stmt(
/*=============================*/ /*=============================*/
trx_t* trx); /*!< in: transaction */ trx_t* trx); /*!< in: transaction */
/***********************************************************************//** /** Drop all orphaned FTS auxiliary tables, those that don't have a parent
Drop all orphaned FTS auxiliary tables, those that don't have a parent
table or FTS index defined on them. */ table or FTS index defined on them. */
void void fts_drop_orphaned_tables();
fts_drop_orphaned_tables(void);
/*==========================*/
/** Run SYNC on the table, i.e., write out data from the cache to the /** Run SYNC on the table, i.e., write out data from the cache to the
FTS auxiliary INDEX table and clear the cache at the end. FTS auxiliary INDEX table and clear the cache at the end.
...@@ -774,15 +771,6 @@ fts_init_doc_id( ...@@ -774,15 +771,6 @@ fts_init_doc_id(
/*============*/ /*============*/
const dict_table_t* table); /*!< in: table */ const dict_table_t* table); /*!< in: table */
/* Get parent table name if it's a fts aux table
@param[in] aux_table_name aux table name
@param[in] aux_table_len aux table length
@return parent table name, or NULL */
char*
fts_get_parent_table_name(
const char* aux_table_name,
ulint aux_table_len);
/******************************************************************//** /******************************************************************//**
compare two character string according to their charset. */ compare two character string according to their charset. */
extern extern
...@@ -989,4 +977,14 @@ and there are no new fts index to add. ...@@ -989,4 +977,14 @@ and there are no new fts index to add.
@param[in] trx transaction to drop all fts tables */ @param[in] trx transaction to drop all fts tables */
void fts_clear_all(dict_table_t *table, trx_t *trx); void fts_clear_all(dict_table_t *table, trx_t *trx);
/** Check whether the given name is fts auxiliary table
and fetch the parent table id and index id
@param[in] name table name
@param[in,out] table_id parent table id
@param[in,out] index_id index id
@return true if it is auxilary table */
bool fts_check_aux_table(const char *name,
table_id_t *table_id,
index_id_t *index_id);
#endif /*!< fts0fts.h */ #endif /*!< fts0fts.h */
...@@ -462,11 +462,7 @@ int ...@@ -462,11 +462,7 @@ int
fts_write_object_id( fts_write_object_id(
/*================*/ /*================*/
ib_id_t id, /*!< in: a table/index id */ ib_id_t id, /*!< in: a table/index id */
char* str, /*!< in: buffer to write the id to */ char* str); /*!< in: buffer to write the id to */
bool hex_format MY_ATTRIBUTE((unused)))
/*!< in: true for fixed hex format,
false for old ambiguous format */
MY_ATTRIBUTE((nonnull));
/******************************************************************//** /******************************************************************//**
Read the table id from the string generated by fts_write_object_id(). Read the table id from the string generated by fts_write_object_id().
@return TRUE if parse successful */ @return TRUE if parse successful */
......
...@@ -32,10 +32,7 @@ int ...@@ -32,10 +32,7 @@ int
fts_write_object_id( fts_write_object_id(
/*================*/ /*================*/
ib_id_t id, /* in: a table/index id */ ib_id_t id, /* in: a table/index id */
char* str, /* in: buffer to write the id to */ char* str) /* in: buffer to write the id to */
bool hex_format MY_ATTRIBUTE((unused)))
/* in: true for fixed hex format,
false for old ambiguous format */
{ {
#ifdef _WIN32 #ifdef _WIN32
...@@ -60,11 +57,6 @@ fts_write_object_id( ...@@ -60,11 +57,6 @@ fts_write_object_id(
#endif /* _WIN32 */ #endif /* _WIN32 */
/* As above, but this is only for those tables failing to rename. */
if (!hex_format) {
return(sprintf(str, "%016llu", (ulonglong) id));
}
return(sprintf(str, "%016llx", (ulonglong) id)); return(sprintf(str, "%016llx", (ulonglong) id));
} }
......
...@@ -3940,9 +3940,21 @@ row_drop_database_for_mysql( ...@@ -3940,9 +3940,21 @@ row_drop_database_for_mysql(
avoid accessing dropped fts aux tables in information avoid accessing dropped fts aux tables in information
scheam when parent table still exists. scheam when parent table still exists.
Note: Drop parent table will drop fts aux tables. */ Note: Drop parent table will drop fts aux tables. */
char* parent_table_name; char* parent_table_name = NULL;
parent_table_name = fts_get_parent_table_name( table_id_t table_id;
table_name, strlen(table_name)); index_id_t index_id;
if (fts_check_aux_table(
table_name, &table_id, &index_id)) {
dict_table_t* parent_table = dict_table_open_on_id(
table_id, TRUE, DICT_TABLE_OP_NORMAL);
if (parent_table != NULL) {
parent_table_name = mem_strdupl(
parent_table->name.m_name,
strlen(parent_table->name.m_name));
dict_table_close(parent_table, TRUE, FALSE);
}
}
if (parent_table_name != NULL) { if (parent_table_name != NULL) {
ut_free(table_name); ut_free(table_name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment