1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-26127 Assertion `err != DB_DUPLICATE_KEY' failed or InnoDB: Failing assertion: id != 0 on ALTER ... REBUILD PARTITION

During rebuild of partition, the partitioning engine calls
alter_close_table(), which does not unlock and close some table
instances of the target table.
Then, the engine fails to rename partitions because there are table
instances that are still locked.

Closing all the table instance of the target table fixes the bug.
This commit is contained in:
Nayuta Yanagisawa
2021-10-29 19:04:53 +09:00
parent d4760d8c01
commit 06e9ce798c
5 changed files with 55 additions and 9 deletions

View File

@ -1,5 +1,5 @@
/* Copyright (c) 2005, 2017, Oracle and/or its affiliates.
Copyright (c) 2009, 2020, MariaDB
Copyright (c) 2009, 2022, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -6817,16 +6817,33 @@ static bool alter_partition_lock_handling(ALTER_PARTITION_PARAM_TYPE *lpt)
static int alter_close_table(ALTER_PARTITION_PARAM_TYPE *lpt)
{
int error= 0;
THD *thd= lpt->thd;
TABLE_SHARE *share= lpt->table->s;
DBUG_ENTER("alter_close_table");
if (lpt->table->db_stat)
{
error= mysql_lock_remove(lpt->thd, lpt->thd->lock, lpt->table);
error= lpt->table->file->ha_close();
lpt->table->db_stat= 0; // Mark file closed
}
DBUG_RETURN(error);
TABLE *table= thd->open_tables;
do {
table= find_locked_table(table, share->db.str, share->table_name.str);
if (!table)
{
DBUG_RETURN(0);
}
if (table->db_stat)
{
if (int error= mysql_lock_remove(thd, thd->lock, table))
{
DBUG_RETURN(error);
}
if (int error= table->file->ha_close())
{
DBUG_RETURN(error);
}
table->db_stat= 0; // Mark file closed
}
} while ((table= table->next));
DBUG_RETURN(0);
}