summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormkaruza <mario.karuza@galeracluster.com>2021-12-09 09:38:03 +0100
committerJan Lindström <jan.lindstrom@mariadb.com>2021-12-14 09:00:08 +0200
commitb1d647ae85d6b9bd08800034492cb6bd166bfa9d (patch)
tree35f77c585959a926d5334d019b911d648d4295b7
parent979b23d5bfb11bb698ea65c9468b374978737ec0 (diff)
downloadmariadb-git-bb-10.7-MDEV-27001.tar.gz
MDEV-27001 Galera crashes when converting table to partitionbb-10.7-MDEV-27001
SQL statments could have table entries added in lexer. This entries should not invalidate `next_global` member. Reviewed-by: Jan Lindström <jan.lindstrom@mariadb.com>
-rw-r--r--mysql-test/suite/galera/r/MDEV-27001.result6
-rw-r--r--mysql-test/suite/galera/t/MDEV-27001.opt1
-rw-r--r--mysql-test/suite/galera/t/MDEV-27001.test7
-rw-r--r--sql/wsrep_mysqld.cc17
4 files changed, 30 insertions, 1 deletions
diff --git a/mysql-test/suite/galera/r/MDEV-27001.result b/mysql-test/suite/galera/r/MDEV-27001.result
new file mode 100644
index 00000000000..f2dc6a9a937
--- /dev/null
+++ b/mysql-test/suite/galera/r/MDEV-27001.result
@@ -0,0 +1,6 @@
+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;
diff --git a/mysql-test/suite/galera/t/MDEV-27001.opt b/mysql-test/suite/galera/t/MDEV-27001.opt
new file mode 100644
index 00000000000..c62d74cb249
--- /dev/null
+++ b/mysql-test/suite/galera/t/MDEV-27001.opt
@@ -0,0 +1 @@
+--partition=ON \ No newline at end of file
diff --git a/mysql-test/suite/galera/t/MDEV-27001.test b/mysql-test/suite/galera/t/MDEV-27001.test
new file mode 100644
index 00000000000..fb5f57f53e5
--- /dev/null
+++ b/mysql-test/suite/galera/t/MDEV-27001.test
@@ -0,0 +1,7 @@
+--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
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc
index d61494e31be..146cd2d7746 100644
--- a/sql/wsrep_mysqld.cc
+++ b/sql/wsrep_mysqld.cc
@@ -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 @@ exit:
/* 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;