mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-25538 Crash on REPAIR VIEW that was created from IS table
Remove calls to wsrep_append_fk_parent_table() during REPAIR/OPTIMIZE TABLE processing. It turns out that REPAIR or OPTIMIZE commands on table t, do not acquire MDL locks on parent tables of t (as shown in the included test). Thus making wsrep_append_fk_parent_table() unnecessary for OPTIMIZE and REPAIR. This also fixes MDEV-24446 and reenables test galera.mysql-wsrep#198. Reviewed-by: Jan Lindström <jan.lindstrom@mariadb.com>
This commit is contained in:
committed by
Jan Lindström
parent
f8c3d59274
commit
c75bee9478
@ -436,49 +436,6 @@ dbug_err:
|
||||
return open_error;
|
||||
}
|
||||
|
||||
#ifdef WITH_WSREP
|
||||
/*
|
||||
OPTIMIZE, REPAIR and ALTER may take MDL locks not only for the affected table, but
|
||||
also for the table referenced by foreign key constraint.
|
||||
This wsrep_toi_replication() function handles TOI replication for OPTIMIZE and REPAIR
|
||||
so that certification keys for potential FK parent tables are also appended in the
|
||||
write set.
|
||||
ALTER TABLE case is handled elsewhere.
|
||||
*/
|
||||
static bool wsrep_toi_replication(THD *thd, TABLE_LIST *tables)
|
||||
{
|
||||
LEX *lex= thd->lex;
|
||||
/* only handle OPTIMIZE and REPAIR here */
|
||||
switch (lex->sql_command)
|
||||
{
|
||||
case SQLCOM_OPTIMIZE:
|
||||
case SQLCOM_REPAIR:
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
close_thread_tables(thd);
|
||||
wsrep::key_array keys;
|
||||
|
||||
wsrep_append_fk_parent_table(thd, tables, &keys);
|
||||
|
||||
/* now TOI replication, with no locks held */
|
||||
if (keys.empty())
|
||||
{
|
||||
if (!thd->lex->no_write_to_binlog &&
|
||||
wsrep_to_isolation_begin(thd, NULL, NULL, tables))
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!thd->lex->no_write_to_binlog &&
|
||||
wsrep_to_isolation_begin(thd, NULL, NULL, tables, NULL, &keys))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif /* WITH_WSREP */
|
||||
|
||||
/*
|
||||
RETURN VALUES
|
||||
@ -550,16 +507,6 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
|
||||
close_thread_tables(thd);
|
||||
for (table= tables; table; table= table->next_local)
|
||||
table->table= NULL;
|
||||
#ifdef WITH_WSREP
|
||||
if (WSREP(thd))
|
||||
{
|
||||
if(wsrep_toi_replication(thd, tables))
|
||||
{
|
||||
WSREP_INFO("wsrep TOI replication of has failed.");
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
#endif /* WITH_WSREP */
|
||||
|
||||
for (table= tables; table; table= table->next_local)
|
||||
{
|
||||
@ -1468,6 +1415,7 @@ bool Sql_cmd_optimize_table::execute(THD *thd)
|
||||
FALSE, UINT_MAX, FALSE))
|
||||
goto error; /* purecov: inspected */
|
||||
|
||||
WSREP_TO_ISOLATION_BEGIN_WRTCHK(NULL, NULL, first_table);
|
||||
res= (specialflag & SPECIAL_NO_NEW_FUNC) ?
|
||||
mysql_recreate_table(thd, first_table, true) :
|
||||
mysql_admin_table(thd, first_table, &m_lex->check_opt,
|
||||
@ -1477,6 +1425,9 @@ bool Sql_cmd_optimize_table::execute(THD *thd)
|
||||
m_lex->first_select_lex()->table_list.first= first_table;
|
||||
m_lex->query_tables= first_table;
|
||||
|
||||
#ifdef WITH_WSREP
|
||||
wsrep_error_label:
|
||||
#endif /* WITH_WSREP */
|
||||
error:
|
||||
DBUG_RETURN(res);
|
||||
}
|
||||
@ -1492,6 +1443,8 @@ bool Sql_cmd_repair_table::execute(THD *thd)
|
||||
if (check_table_access(thd, SELECT_ACL | INSERT_ACL, first_table,
|
||||
FALSE, UINT_MAX, FALSE))
|
||||
goto error; /* purecov: inspected */
|
||||
|
||||
WSREP_TO_ISOLATION_BEGIN_WRTCHK(NULL, NULL, first_table);
|
||||
res= mysql_admin_table(thd, first_table, &m_lex->check_opt, "repair",
|
||||
TL_WRITE, 1,
|
||||
MY_TEST(m_lex->check_opt.sql_flags & TT_USEFRM),
|
||||
@ -1501,6 +1454,9 @@ bool Sql_cmd_repair_table::execute(THD *thd)
|
||||
m_lex->first_select_lex()->table_list.first= first_table;
|
||||
m_lex->query_tables= first_table;
|
||||
|
||||
#ifdef WITH_WSREP
|
||||
wsrep_error_label:
|
||||
#endif /* WITH_WSREP */
|
||||
error:
|
||||
DBUG_RETURN(res);
|
||||
}
|
||||
|
Reference in New Issue
Block a user