mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Backport of revno: 3702
Bug #48248 assert in MDL_ticket::upgrade_shared_lock_to_exclusive The assert would happen if REPAIR TABLE was used on a table already locked by LOCK TABLES READ. REPAIR mistakenly tried to upgrade the read-lock to exclusive, thereby triggering the assert. The cause of the problem was that REPAIR TABLE ignored errors from opening and locking tables. This is by design, as REPAIR can be used to broken tables that cannot be opened. However, repair also ignored logical errors such as the inability to exclusivly lock a table due to conflicting LOCK TABLES. This patch fixes the problem by not ignoring errors from opening and locking tables if inside LOCK TABLES mode. In LOCK TABLES we already know that the table can be opened, so that the failure to open must be a logical error. Test added to repair.test.
This commit is contained in:
@ -4548,6 +4548,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
|
||||
char table_name[NAME_LEN*2+2];
|
||||
char* db = table->db;
|
||||
bool fatal_error=0;
|
||||
bool open_error;
|
||||
|
||||
DBUG_PRINT("admin", ("table: '%s'.'%s'", table->db, table->table_name));
|
||||
DBUG_PRINT("admin", ("extra_open_options: %u", extra_open_options));
|
||||
@ -4575,12 +4576,22 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
|
||||
if (view_operator_func == NULL)
|
||||
table->required_type=FRMTYPE_TABLE;
|
||||
|
||||
open_and_lock_tables_derived(thd, table, TRUE,
|
||||
MYSQL_OPEN_TAKE_UPGRADABLE_MDL);
|
||||
open_error= open_and_lock_tables_derived(thd, table, TRUE,
|
||||
MYSQL_OPEN_TAKE_UPGRADABLE_MDL);
|
||||
thd->no_warnings_for_error= 0;
|
||||
table->next_global= save_next_global;
|
||||
table->next_local= save_next_local;
|
||||
thd->open_options&= ~extra_open_options;
|
||||
/*
|
||||
Under locked tables, we know that the table can be opened,
|
||||
so any errors opening the table are logical errors.
|
||||
In these cases it does not make sense to try to repair.
|
||||
*/
|
||||
if (open_error && thd->locked_tables_mode)
|
||||
{
|
||||
result_code= HA_ADMIN_FAILED;
|
||||
goto send_result;
|
||||
}
|
||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||
if (table->table)
|
||||
{
|
||||
|
Reference in New Issue
Block a user