Skip to content

Commit a909976

Browse files
author
bin.x.su@oracle.com
committedApr 29, 2014
Bug #18634201 - Upgrade from 5.6.10 to 5.6.16 crashes and leaves unausable DB
When user tries to upgrade from 5.6.10 to latest 5.6, the rename of aux tables could make server crash, since we don't get rid of those obsolete tables, which were removed away since 5.6.11. The patch fixed 2 issues: 1) We shouldn't try to rename those obsolete tables. 2) We should try to drop those obsolete tables when upgrade, so that those obsolete tables would not be left in the data directory. rb#5202, approved by Jimmy.
2 parents de8d9e0 + 3fad85b commit a909976

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
 

‎storage/innobase/fts/fts0fts.cc

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ static const ulint FTS_MAX_ID_LEN = 32;
4444
/** Column name from the FTS config table */
4545
#define FTS_MAX_CACHE_SIZE_IN_MB "cache_size_in_mb"
4646

47+
/** Verify if a aux table name is a obsolete table
48+
by looking up the key word in the obsolete table names */
49+
#define FTS_IS_OBSOLETE_AUX_TABLE(table_name) \
50+
(strstr((table_name), "DOC_ID") != NULL \
51+
|| strstr((table_name), "ADDED") != NULL \
52+
|| strstr((table_name), "STOPWORDS") != NULL)
53+
4754
/** This is maximum FTS cache for each table and would be
4855
a configurable variable */
4956
ulong fts_max_cache_size;
@@ -6038,6 +6045,12 @@ fts_is_aux_table_name(
60386045
}
60396046
}
60406047

6048+
/* Could be obsolete common tables. */
6049+
if (strncmp(ptr, "ADDED", len) == 0
6050+
|| strncmp(ptr, "STOPWORDS", len) == 0) {
6051+
return(true);
6052+
}
6053+
60416054
/* Try and read the index id. */
60426055
if (!fts_read_object_id(&table->index_id, ptr)) {
60436056
return(FALSE);
@@ -6631,6 +6644,56 @@ fts_check_and_drop_orphaned_tables(
66316644
::ut_free(path);
66326645
}
66336646
}
6647+
} else {
6648+
if (FTS_IS_OBSOLETE_AUX_TABLE(aux_table->name)) {
6649+
6650+
/* Current table could be one of the three
6651+
obsolete tables, in this case, we should
6652+
always try to drop it but not rename it.
6653+
This could happen when we try to upgrade
6654+
from older server to later one, which doesn't
6655+
contain these obsolete tables. */
6656+
drop = true;
6657+
6658+
dberr_t err;
6659+
trx_t* trx_drop =
6660+
trx_allocate_for_background();
6661+
6662+
trx_drop->op_info = "Drop obsolete aux tables";
6663+
trx_drop->dict_operation_lock_mode = RW_X_LATCH;
6664+
6665+
trx_start_for_ddl(trx_drop, TRX_DICT_OP_TABLE);
6666+
6667+
err = row_drop_table_for_mysql(
6668+
aux_table->name, trx_drop, false, true);
6669+
6670+
trx_drop->dict_operation_lock_mode = 0;
6671+
6672+
if (err != DB_SUCCESS) {
6673+
/* We don't need to worry about the
6674+
failure, since server would try to
6675+
drop it on next restart, even if
6676+
the table was broken. */
6677+
6678+
ib_logf(IB_LOG_LEVEL_WARN,
6679+
"Fail to drop obsolete aux"
6680+
" table '%s', which is"
6681+
" harmless. will try to drop"
6682+
" it on next restart.",
6683+
aux_table->name);
6684+
6685+
fts_sql_rollback(trx_drop);
6686+
} else {
6687+
ib_logf(IB_LOG_LEVEL_INFO,
6688+
"Dropped obsolete aux"
6689+
" table '%s'.",
6690+
aux_table->name);
6691+
6692+
fts_sql_commit(trx_drop);
6693+
}
6694+
6695+
trx_free_for_background(trx_drop);
6696+
}
66346697
}
66356698
#ifdef _WIN32
66366699
if (!drop && rename) {

0 commit comments

Comments
 (0)
Please sign in to comment.