Commit 32e3b022 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-11639 Server crashes in update_virtual_field, gcol.innodb_virtual_basic fails in buildbot

don't use thd->query_id check in background purge threads
(it doesn't work, because thd->query_id is never incremented there)
instead use thd->open_tables directly, there can be only one table
there anyway, and this is the table opened by this purge thread.
parent 95e6dd44
...@@ -4448,6 +4448,14 @@ TABLE *open_purge_table(THD *thd, const char *db, size_t dblen, ...@@ -4448,6 +4448,14 @@ TABLE *open_purge_table(THD *thd, const char *db, size_t dblen,
DBUG_RETURN(error ? NULL : tl->table); DBUG_RETURN(error ? NULL : tl->table);
} }
TABLE *get_purge_table(THD *thd)
{
/* see above, at most one table can be opened */
DBUG_ASSERT(thd->open_tables == NULL || thd->open_tables->next == NULL);
return thd->open_tables;
}
/** Find an open table in the list of prelocked tabled /** Find an open table in the list of prelocked tabled
Used for foreign key actions, for example, in UPDATE t1 SET a=1; Used for foreign key actions, for example, in UPDATE t1 SET a=1;
......
...@@ -132,6 +132,7 @@ void destroy_thd(MYSQL_THD thd); ...@@ -132,6 +132,7 @@ void destroy_thd(MYSQL_THD thd);
void reset_thd(MYSQL_THD thd); void reset_thd(MYSQL_THD thd);
TABLE *open_purge_table(THD *thd, const char *db, size_t dblen, TABLE *open_purge_table(THD *thd, const char *db, size_t dblen,
const char *tb, size_t tblen); const char *tb, size_t tblen);
TABLE *get_purge_table(THD *thd);
/** Check if user has used xtradb extended system variable that /** Check if user has used xtradb extended system variable that
is not currently supported by innodb or marked as deprecated. */ is not currently supported by innodb or marked as deprecated. */
...@@ -22119,8 +22120,17 @@ innobase_find_mysql_table_for_vc( ...@@ -22119,8 +22120,17 @@ innobase_find_mysql_table_for_vc(
THD* thd, THD* thd,
dict_table_t* table) dict_table_t* table)
{ {
if (table->vc_templ->mysql_table_query_id == thd_get_query_id(thd)) { TABLE *mysql_table;
return table->vc_templ->mysql_table; bool bg_thread = THDVAR(thd, background_thread);
if (bg_thread) {
if ((mysql_table = get_purge_table(thd))) {
return mysql_table;
}
} else {
if (table->vc_templ->mysql_table_query_id == thd_get_query_id(thd)) {
return table->vc_templ->mysql_table;
}
} }
char dbname[MAX_DATABASE_NAME_LEN + 1]; char dbname[MAX_DATABASE_NAME_LEN + 1];
...@@ -22150,15 +22160,14 @@ innobase_find_mysql_table_for_vc( ...@@ -22150,15 +22160,14 @@ innobase_find_mysql_table_for_vc(
tbnamelen = filename_to_tablename(tbname, t_tbname, tbnamelen = filename_to_tablename(tbname, t_tbname,
MAX_TABLE_NAME_LEN + 1); MAX_TABLE_NAME_LEN + 1);
TABLE *mysql_table = find_fk_open_table(thd, t_dbname, dbnamelen, if (bg_thread) {
t_tbname, tbnamelen); return open_purge_table(thd, t_dbname, dbnamelen,
t_tbname, tbnamelen);
if (!mysql_table && THDVAR(thd, background_thread)) {
/* only open the table in background purge threads */
mysql_table = open_purge_table(thd, t_dbname, dbnamelen,
t_tbname, tbnamelen);
} }
mysql_table = find_fk_open_table(thd, t_dbname, dbnamelen,
t_tbname, tbnamelen);
table->vc_templ->mysql_table = mysql_table; table->vc_templ->mysql_table = mysql_table;
table->vc_templ->mysql_table_query_id = thd_get_query_id(thd); table->vc_templ->mysql_table_query_id = thd_get_query_id(thd);
return mysql_table; return mysql_table;
......
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