MDEV-27861: Creating partitioned tables should not be allowed with wsrep_osu_method=TOI and wsrep_strict_ddl=ON

Problem was incorrect handling of partitioned tables,
because db_type == DB_TYPE_PARTITION_DB
wsrep_should_replicate_ddl incorrectly marked
DDL as not replicatable. However, in partitioned
tables we should check implementing storage engine
from table->file->partition_ht() if available because
if partition handler is InnoDB all DDL should be allowed
even with wsrep_strict_ddl. For other storage engines
DDL should not be allowed and error should be issued.

This is 10.6 version of the fix.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
This commit is contained in:
Jan Lindström 2023-07-17 17:29:20 +03:00 committed by Julius Goryavsky
parent b3925982a0
commit 9389428380
4 changed files with 56 additions and 46 deletions

View file

@ -1,10 +1,11 @@
connection node_2;
connection node_1;
# wsrep-strict_ddl = OFF
SET GLOBAL wsrep_strict_ddl = OFF;
SELECT @@wsrep_strict_ddl;
@@wsrep_strict_ddl
0
call mtr.add_suppression("WSREP: wsrep_mode = STRICT_REPLICATION enabled. Storage engine partition for table.*");
# wsrep-mode= DEFAULT
SET GLOBAL wsrep_mode = "";
SELECT @@wsrep_mode;
@@wsrep_mode
CREATE OR REPLACE TABLE t1 (v1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB
PARTITION BY KEY (v1)
PARTITIONS 2;
@ -73,55 +74,63 @@ DROP TRIGGER increment_before_t1;
DROP TRIGGER increment_before_t2;
DROP TABLE t1_v2;
DROP TABLE t2_v2;
SET GLOBAL wsrep_strict_ddl = OFF;
SET GLOBAL wsrep_mode = "";
CREATE OR REPLACE TABLE t2 (v1 INT NOT NULL PRIMARY KEY) ENGINE=MyISAM
PARTITION BY KEY (v1)
PARTITIONS 2;
# wsrep-strict_ddl = ON
SET GLOBAL wsrep_strict_ddl = ON;
SELECT @@wsrep_strict_ddl;
@@wsrep_strict_ddl
1
# wsrep-mode= STRICT_REPLICATION
SET GLOBAL wsrep_mode = "STRICT_REPLICATION";
SELECT @@wsrep_mode;
@@wsrep_mode
STRICT_REPLICATION
CREATE OR REPLACE TABLE t1 (v1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB
PARTITION BY KEY (v1)
PARTITIONS 2;
CREATE OR REPLACE TABLE t3 (v1 INT NOT NULL PRIMARY KEY) ENGINE=MyISAM
PARTITION BY KEY (v1)
PARTITIONS 2;
ERROR HY000: DDL-statement is forbidden as table storage engine does not support Galera replication
ERROR HY000: Galera replication not supported
ALTER TABLE t1 ADD COLUMN v2 int;
ALTER TABLE t2 ADD COLUMN v2 int;
ERROR HY000: DDL-statement is forbidden as table storage engine does not support Galera replication
ERROR HY000: Galera replication not supported
INSERT INTO t1 VALUES (1,1),(2,2);
Warnings:
Warning 1290 WSREP: wsrep_mode = STRICT_REPLICATION enabled. Storage engine partition for table 'test'.'t1' is not supported in Galera
INSERT INTO t2 VALUES (1),(2);
Warnings:
Warning 1290 WSREP: wsrep_mode = STRICT_REPLICATION enabled. Storage engine partition for table 'test'.'t2' is not supported in Galera
ALTER TABLE t1 ADD COLUMN v3 int, ENGINE=MyISAM;
ERROR HY000: DDL-statement is forbidden as table storage engine does not support Galera replication
ERROR HY000: Galera replication not supported
ALTER TABLE t2 ADD COLUMN v3 int, ENGINE=Aria;
ERROR HY000: DDL-statement is forbidden as table storage engine does not support Galera replication
ERROR HY000: Galera replication not supported
UPDATE t1 SET v2 = v2 + 3;
Warnings:
Warning 1290 WSREP: wsrep_mode = STRICT_REPLICATION enabled. Storage engine partition for table 'test'.'t1' is not supported in Galera
UPDATE t2 SET v1 = v1 + 3;
Warnings:
Warning 1290 WSREP: wsrep_mode = STRICT_REPLICATION enabled. Storage engine partition for table 'test'.'t2' is not supported in Galera
CREATE INDEX xx1 ON t1(v2);
CREATE INDEX xx2 ON t2(v2);
ERROR HY000: DDL-statement is forbidden as table storage engine does not support Galera replication
ERROR HY000: Galera replication not supported
DROP INDEX xx1 ON t1;
DROP INDEX xx2 on t2;
ERROR HY000: DDL-statement is forbidden as table storage engine does not support Galera replication
ERROR HY000: Galera replication not supported
TRUNCATE TABLE t1;
TRUNCATE TABLE t2;
ERROR HY000: DDL-statement is forbidden as table storage engine does not support Galera replication
ERROR HY000: Galera replication not supported
RENAME TABLE t1 TO t1_v2;
RENAME TABLE t2 TO t2_v2;
RENAME TABLE t2_v2 TO t2;
CREATE VIEW x1 AS SELECT * FROM t1_v2;
CREATE VIEW x2 AS SELECT * FROM t2;
ERROR HY000: DDL-statement is forbidden as table storage engine does not support Galera replication
ERROR HY000: Galera replication not supported
CREATE DEFINER=`root`@`localhost` TRIGGER increment_before_t1
AFTER INSERT ON t1_v2 FOR EACH ROW
UPDATE t1_v2 SET t1_v2.v2 = t1_v2.v2+1;
CREATE DEFINER=`root`@`localhost` TRIGGER increment_before_t2
AFTER INSERT ON t2 FOR EACH ROW
UPDATE t2 SET t2.v1 = t2.v1+1;
ERROR HY000: DDL-statement is forbidden as table storage engine does not support Galera replication
ERROR HY000: Galera replication not supported
connection node_2;
SHOW CREATE TABLE t1_v2;
Table Create Table
@ -153,15 +162,15 @@ DROP VIEW x1;
DROP TRIGGER increment_before_t1;
DROP TABLE t1_v2;
DROP TABLE t2;
SET GLOBAL wsrep_strict_ddl=OFF;
SET GLOBAL wsrep_mode = "";
CREATE OR REPLACE TABLE t2 (v1 INT NOT NULL PRIMARY KEY) ENGINE=MyISAM
PARTITION BY KEY (v1)
PARTITIONS 2;
# wsrep-strict_ddl = ON
SET GLOBAL wsrep_strict_ddl = ON;
SELECT @@wsrep_strict_ddl;
@@wsrep_strict_ddl
1
# wsrep-mode= STRICT_REPLICATION
SET GLOBAL wsrep_mode = "STRICT_REPLICATION";
SELECT @@wsrep_mode;
@@wsrep_mode
STRICT_REPLICATION
ALTER TABLE t2 ENGINE=InnoDB;
DROP TABLE t2;
SET GLOBAL wsrep_strict_ddl = DEFAULT;
SET GLOBAL wsrep_mode = DEFAULT;

View file

@ -19,8 +19,8 @@ CREATE TABLE t1(a int) engine=Aria;
ERROR HY000: Galera replication not supported
SHOW WARNINGS;
Level Code Message
Error 4165 DDL-statement is forbidden as table storage engine does not support Galera replication
Warning 1031 WSREP: wsrep_strict_dll enabled. Storage engine Aria not supported.
Error 4165 Galera replication not supported
Warning 1031 WSREP: wsrep_mode = STRICT_REPLICATION enabled. Storage engine Aria not supported.
connection node_2;
SHOW CREATE TABLE t1;
ERROR 42S02: Table 'test.t1' doesn't exist
@ -30,10 +30,10 @@ ALTER TABLE t2 engine=MyISAM;
ERROR HY000: Galera replication not supported
SHOW WARNINGS;
Level Code Message
Error 4165 DDL-statement is forbidden as table storage engine does not support Galera replication
Warning 1031 WSREP: wsrep_strict_dll enabled. Storage engine MyISAM not supported.
Error 4165 DDL-statement is forbidden as table storage engine does not support Galera replication
Warning 1031 WSREP: wsrep_strict_dll enabled. Storage engine MyISAM not supported.
Error 4165 Galera replication not supported
Warning 1031 WSREP: wsrep_mode = STRICT_REPLICATION enabled. Storage engine MyISAM not supported.
Error 4165 Galera replication not supported
Warning 1031 WSREP: wsrep_mode = STRICT_REPLICATION enabled. Storage engine MyISAM not supported.
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (

View file

@ -3,9 +3,11 @@
--source include/have_innodb.inc
--source include/have_aria.inc
--echo # wsrep-strict_ddl = OFF
SET GLOBAL wsrep_strict_ddl = OFF;
SELECT @@wsrep_strict_ddl;
call mtr.add_suppression("WSREP: wsrep_mode = STRICT_REPLICATION enabled. Storage engine partition for table.*");
--echo # wsrep-mode= DEFAULT
SET GLOBAL wsrep_mode = "";
SELECT @@wsrep_mode;
CREATE OR REPLACE TABLE t1 (v1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB
PARTITION BY KEY (v1)
PARTITIONS 2;
@ -54,13 +56,13 @@ DROP TRIGGER increment_before_t2;
DROP TABLE t1_v2;
DROP TABLE t2_v2;
SET GLOBAL wsrep_strict_ddl = OFF;
SET GLOBAL wsrep_mode = "";
CREATE OR REPLACE TABLE t2 (v1 INT NOT NULL PRIMARY KEY) ENGINE=MyISAM
PARTITION BY KEY (v1)
PARTITIONS 2;
--echo # wsrep-strict_ddl = ON
SET GLOBAL wsrep_strict_ddl = ON;
SELECT @@wsrep_strict_ddl;
--echo # wsrep-mode= STRICT_REPLICATION
SET GLOBAL wsrep_mode = "STRICT_REPLICATION";
SELECT @@wsrep_mode;
CREATE OR REPLACE TABLE t1 (v1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB
PARTITION BY KEY (v1)
PARTITIONS 2;
@ -117,15 +119,15 @@ DROP TRIGGER increment_before_t1;
DROP TABLE t1_v2;
# We allow dropping table
DROP TABLE t2;
SET GLOBAL wsrep_strict_ddl=OFF;
SET GLOBAL wsrep_mode = "";
CREATE OR REPLACE TABLE t2 (v1 INT NOT NULL PRIMARY KEY) ENGINE=MyISAM
PARTITION BY KEY (v1)
PARTITIONS 2;
--echo # wsrep-strict_ddl = ON
SET GLOBAL wsrep_strict_ddl = ON;
SELECT @@wsrep_strict_ddl;
--echo # wsrep-mode= STRICT_REPLICATION
SET GLOBAL wsrep_mode = "STRICT_REPLICATION";
SELECT @@wsrep_mode;
ALTER TABLE t2 ENGINE=InnoDB;
DROP TABLE t2;
SET GLOBAL wsrep_strict_ddl = DEFAULT;
SET GLOBAL wsrep_mode = DEFAULT;

View file

@ -614,7 +614,6 @@ bool wsrep_table_list_has_non_temp_tables(THD *thd, TABLE_LIST *tables);
#define wsrep_thr_deinit() do {} while(0)
#define wsrep_init_globals() do {} while(0)
#define wsrep_create_appliers(X) do {} while(0)
#define wsrep_should_replicate_ddl(X,Y) (1)
#define wsrep_cluster_address_exists() (false)
#define WSREP_MYSQL_DB (0)
#define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) do { } while(0)