mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
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.
This commit is contained in:
@ -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);
|
|||||||
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,9 +22120,18 @@ innobase_find_mysql_table_for_vc(
|
|||||||
THD* thd,
|
THD* thd,
|
||||||
dict_table_t* table)
|
dict_table_t* table)
|
||||||
{
|
{
|
||||||
|
TABLE *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)) {
|
if (table->vc_templ->mysql_table_query_id == thd_get_query_id(thd)) {
|
||||||
return table->vc_templ->mysql_table;
|
return table->vc_templ->mysql_table;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
char dbname[MAX_DATABASE_NAME_LEN + 1];
|
char dbname[MAX_DATABASE_NAME_LEN + 1];
|
||||||
char tbname[MAX_TABLE_NAME_LEN + 1];
|
char tbname[MAX_TABLE_NAME_LEN + 1];
|
||||||
@ -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,
|
||||||
|
|
||||||
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);
|
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;
|
||||||
|
Reference in New Issue
Block a user