Commit b1d647ae authored by mkaruza's avatar mkaruza Committed by Jan Lindström

MDEV-27001 Galera crashes when converting table to partition

SQL statments could have table entries added in lexer. This entries
should not invalidate `next_global` member.
Reviewed-by: default avatarJan Lindström <jan.lindstrom@mariadb.com>
parent 979b23d5
connection node_2;
connection node_1;
CREATE TABLE t3 (c INT) PARTITION BY RANGE (c) (PARTITION p1 VALUES LESS THAN (1000));
CREATE TABLE tp2 (c INT);
ALTER TABLE t3 CONVERT TABLE tp2 TO PARTITION p2 VALUES LESS THAN (2000);
DROP TABLE t3;
--partition=ON
\ No newline at end of file
--source include/galera_cluster.inc
--source include/have_innodb.inc
CREATE TABLE t3 (c INT) PARTITION BY RANGE (c) (PARTITION p1 VALUES LESS THAN (1000));
CREATE TABLE tp2 (c INT);
ALTER TABLE t3 CONVERT TABLE tp2 TO PARTITION p2 VALUES LESS THAN (2000);
DROP TABLE t3;
\ No newline at end of file
......@@ -1603,11 +1603,18 @@ wsrep_append_fk_parent_table(THD* thd, TABLE_LIST* tables, wsrep::key_array* key
{
bool fail= false;
TABLE_LIST *table;
TABLE_LIST *table_last_in_list;
thd->release_transactional_locks();
uint counter;
MDL_savepoint mdl_savepoint= thd->mdl_context.mdl_savepoint();
for (table_last_in_list= tables;;table_last_in_list= table_last_in_list->next_local) {
if (!table_last_in_list->next_local) {
break;
}
}
if (thd->open_temporary_tables(tables) ||
open_tables(thd, &tables, &counter, MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL))
{
......@@ -1639,11 +1646,19 @@ wsrep_append_fk_parent_table(THD* thd, TABLE_LIST* tables, wsrep::key_array* key
/* close the table and release MDL locks */
close_thread_tables(thd);
thd->mdl_context.rollback_to_savepoint(mdl_savepoint);
bool invalidate_next_global= false;
for (table= tables; table; table= table->next_local)
{
table->table= NULL;
table->next_global= NULL;
table->mdl_request.ticket= NULL;
// We should invalidate `next_global` only for entries that are added
// in this function
if (table == table_last_in_list) {
invalidate_next_global= true;
}
if (invalidate_next_global) {
table->next_global= NULL;
}
}
return fail;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment