1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-30364 Assertion MDL_EXCLUSIVE on DISCARD TABLESPACE in LOCK TABLE mode

In locked_tables_mode when table is opened without
MYSQL_OPEN_GET_NEW_TABLE flag it is taken from pre-opened and locked
tables. In that case we upgrade its MDL ticket to MDL_EXCLUSIVE before
the operation and downgrade after operation.
This commit is contained in:
Aleksey Midenkov
2025-07-08 14:01:50 +03:00
committed by Sergei Golubchik
parent db3e1edac3
commit aedc65fe10
3 changed files with 87 additions and 1 deletions

View File

@@ -5946,6 +5946,8 @@ int mysql_discard_or_import_tablespace(THD *thd,
{
Alter_table_prelocking_strategy alter_prelocking_strategy;
int error;
TABLE *table;
enum_mdl_type mdl_downgrade= MDL_NOT_INITIALIZED;
DBUG_ENTER("mysql_discard_or_import_tablespace");
mysql_audit_alter_table(thd, table_list);
@@ -5978,7 +5980,21 @@ int mysql_discard_or_import_tablespace(THD *thd,
DBUG_RETURN(-1);
}
error= table_list->table->file->ha_discard_or_import_tablespace(discard);
table= table_list->table;
DBUG_ASSERT(table->mdl_ticket || table->s->tmp_table);
if (table->mdl_ticket && table->mdl_ticket->get_type() < MDL_EXCLUSIVE)
{
DBUG_ASSERT(thd->locked_tables_mode);
mdl_downgrade= table->mdl_ticket->get_type();
if (thd->mdl_context.upgrade_shared_lock(table->mdl_ticket, MDL_EXCLUSIVE,
thd->variables.lock_wait_timeout))
{
error= 1;
goto err;
}
}
error= table->file->ha_discard_or_import_tablespace(discard);
THD_STAGE_INFO(thd, stage_end);
@@ -6004,6 +6020,9 @@ int mysql_discard_or_import_tablespace(THD *thd,
err:
thd->tablespace_op=FALSE;
if (mdl_downgrade > MDL_NOT_INITIALIZED)
table->mdl_ticket->downgrade_lock(mdl_downgrade);
if (likely(error == 0))
{
my_ok(thd);