Skip to content

Commit f9bdff6

Browse files
committed
MDEV-37373 : InnoDB partition table disallow local GTIDs in galera
Problem was that for partitioned tables base table storage engine is DB_TYPE_PARTITION_DB and naturally different than DB_TYPE_INNODB so operation was not allowed in Galera. Fixed by requesting implementing storage engine for partitioned tables i.e. table->file->partition_ht() or if that does not exist we can use base table storage engine. Resulting storage engine type is then used on condition is operation allowed when wsrep_mode=DISALLOW_LOCAL_GTID or not. Operations to InnoDB storage engine i.e DB_TYPE_INNODB should be allowed.
1 parent 573d3ad commit f9bdff6

File tree

4 files changed

+109
-8
lines changed

4 files changed

+109
-8
lines changed

mysql-test/suite/galera/r/galera_partitioned_tables.result

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ ALTER TABLE t1 ADD COLUMN v2 int;
9494
ALTER TABLE t2 ADD COLUMN v2 int;
9595
ERROR HY000: Galera replication not supported
9696
INSERT INTO t1 VALUES (1,1),(2,2);
97-
Warnings:
98-
Warning 1290 WSREP: wsrep_mode = STRICT_REPLICATION enabled. Storage engine partition for table 'test'.'t1' is not supported in Galera
9997
INSERT INTO t2 VALUES (1),(2);
10098
Warnings:
10199
Warning 1290 WSREP: wsrep_mode = STRICT_REPLICATION enabled. Storage engine partition for table 'test'.'t2' is not supported in Galera
@@ -104,8 +102,6 @@ ERROR HY000: Galera replication not supported
104102
ALTER TABLE t2 ADD COLUMN v3 int, ENGINE=Aria;
105103
ERROR HY000: Galera replication not supported
106104
UPDATE t1 SET v2 = v2 + 3;
107-
Warnings:
108-
Warning 1290 WSREP: wsrep_mode = STRICT_REPLICATION enabled. Storage engine partition for table 'test'.'t1' is not supported in Galera
109105
UPDATE t2 SET v1 = v1 + 3;
110106
Warnings:
111107
Warning 1290 WSREP: wsrep_mode = STRICT_REPLICATION enabled. Storage engine partition for table 'test'.'t2' is not supported in Galera
@@ -173,4 +169,61 @@ SELECT @@wsrep_mode;
173169
STRICT_REPLICATION
174170
ALTER TABLE t2 ENGINE=InnoDB;
175171
DROP TABLE t2;
176-
SET GLOBAL wsrep_mode = DEFAULT;
172+
connection node_1;
173+
#
174+
# MDEV-37373 InnoDB partition table disallow local GTIDs in galera
175+
# wsrep-mode= DISALLOW_LOCAL_GTID
176+
#
177+
SET GLOBAL wsrep_mode = "DISALLOW_LOCAL_GTID";
178+
SELECT @@wsrep_mode;
179+
@@wsrep_mode
180+
DISALLOW_LOCAL_GTID
181+
CREATE TABLE `sales` (
182+
`customer_id` int(11) NOT NULL,
183+
`customer_name` varchar(40) DEFAULT NULL,
184+
`store_id` varchar(20) NOT NULL,
185+
`bill_number` int(11) NOT NULL,
186+
`bill_date` date NOT NULL,
187+
`amount` decimal(8,2) NOT NULL,
188+
PRIMARY KEY (`bill_date`)
189+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
190+
PARTITION BY RANGE (year(`bill_date`))
191+
(PARTITION `p0` VALUES LESS THAN (2016) ENGINE = InnoDB,
192+
PARTITION `p1` VALUES LESS THAN (2017) ENGINE = InnoDB,
193+
PARTITION `p2` VALUES LESS THAN (2018) ENGINE = InnoDB,
194+
PARTITION `p3` VALUES LESS THAN (2020) ENGINE = InnoDB);
195+
INSERT INTO sales
196+
VALUES (1, 'Michael', 'S001', 101, '2015-01-02', 125.56),
197+
(2, 'Jim', 'S003', 103, '2015-01-25', 476.50),
198+
(3, 'Dwight', 'S012', 122, '2016-02-15', 335.00),
199+
(4, 'Andy', 'S345', 121, '2016-03-26', 787.00),
200+
(5, 'Pam', 'S234', 132, '2017-04-19', 678.00),
201+
(6, 'Karen', 'S743', 111, '2017-05-31', 864.00),
202+
(7, 'Toby', 'S234', 115, '2018-06-11', 762.00),
203+
(8, 'Oscar', 'S012', 125, '2019-07-24', 300.00),
204+
(9, 'Darryl', 'S456', 119, '2019-08-02', 492.20);
205+
SELECT * FROM sales;
206+
customer_id customer_name store_id bill_number bill_date amount
207+
1 Michael S001 101 2015-01-02 125.56
208+
2 Jim S003 103 2015-01-25 476.50
209+
3 Dwight S012 122 2016-02-15 335.00
210+
4 Andy S345 121 2016-03-26 787.00
211+
5 Pam S234 132 2017-04-19 678.00
212+
6 Karen S743 111 2017-05-31 864.00
213+
7 Toby S234 115 2018-06-11 762.00
214+
8 Oscar S012 125 2019-07-24 300.00
215+
9 Darryl S456 119 2019-08-02 492.20
216+
SET GLOBAL wsrep_mode=DEFAULT;
217+
connection node_2;
218+
SELECT * FROM sales;
219+
customer_id customer_name store_id bill_number bill_date amount
220+
1 Michael S001 101 2015-01-02 125.56
221+
2 Jim S003 103 2015-01-25 476.50
222+
3 Dwight S012 122 2016-02-15 335.00
223+
4 Andy S345 121 2016-03-26 787.00
224+
5 Pam S234 132 2017-04-19 678.00
225+
6 Karen S743 111 2017-05-31 864.00
226+
7 Toby S234 115 2018-06-11 762.00
227+
8 Oscar S012 125 2019-07-24 300.00
228+
9 Darryl S456 119 2019-08-02 492.20
229+
DROP TABLE sales;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[binlogon]
2+
log-bin
3+
log-slave-updates
4+
5+
[binlogoff]

mysql-test/suite/galera/t/galera_partitioned_tables.test

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,41 @@ SELECT @@wsrep_mode;
130130
ALTER TABLE t2 ENGINE=InnoDB;
131131
DROP TABLE t2;
132132

133-
SET GLOBAL wsrep_mode = DEFAULT;
133+
--connection node_1
134+
--echo #
135+
--echo # MDEV-37373 InnoDB partition table disallow local GTIDs in galera
136+
--echo # wsrep-mode= DISALLOW_LOCAL_GTID
137+
--echo #
138+
SET GLOBAL wsrep_mode = "DISALLOW_LOCAL_GTID";
139+
SELECT @@wsrep_mode;
140+
CREATE TABLE `sales` (
141+
`customer_id` int(11) NOT NULL,
142+
`customer_name` varchar(40) DEFAULT NULL,
143+
`store_id` varchar(20) NOT NULL,
144+
`bill_number` int(11) NOT NULL,
145+
`bill_date` date NOT NULL,
146+
`amount` decimal(8,2) NOT NULL,
147+
PRIMARY KEY (`bill_date`)
148+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
149+
PARTITION BY RANGE (year(`bill_date`))
150+
(PARTITION `p0` VALUES LESS THAN (2016) ENGINE = InnoDB,
151+
PARTITION `p1` VALUES LESS THAN (2017) ENGINE = InnoDB,
152+
PARTITION `p2` VALUES LESS THAN (2018) ENGINE = InnoDB,
153+
PARTITION `p3` VALUES LESS THAN (2020) ENGINE = InnoDB);
154+
155+
INSERT INTO sales
156+
VALUES (1, 'Michael', 'S001', 101, '2015-01-02', 125.56),
157+
(2, 'Jim', 'S003', 103, '2015-01-25', 476.50),
158+
(3, 'Dwight', 'S012', 122, '2016-02-15', 335.00),
159+
(4, 'Andy', 'S345', 121, '2016-03-26', 787.00),
160+
(5, 'Pam', 'S234', 132, '2017-04-19', 678.00),
161+
(6, 'Karen', 'S743', 111, '2017-05-31', 864.00),
162+
(7, 'Toby', 'S234', 115, '2018-06-11', 762.00),
163+
(8, 'Oscar', 'S012', 125, '2019-07-24', 300.00),
164+
(9, 'Darryl', 'S456', 119, '2019-08-02', 492.20);
165+
166+
SELECT * FROM sales;
167+
SET GLOBAL wsrep_mode=DEFAULT;
168+
--connection node_2
169+
SELECT * FROM sales;
170+
DROP TABLE sales;

sql/wsrep_mysqld.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,10 +1444,16 @@ bool wsrep_check_mode_after_open_table (THD *thd,
14441444
if (!is_dml_stmt)
14451445
return true;
14461446

1447-
const legacy_db_type db_type= hton->db_type;
1447+
TABLE *tbl= tables->table;
1448+
/* If this is partitioned table we need to find out
1449+
implementing storage engine handlerton.
1450+
*/
1451+
const handlerton *ht= tbl->file->partition_ht();
1452+
if (!ht) ht= hton;
1453+
1454+
const legacy_db_type db_type= ht->db_type;
14481455
bool replicate= ((db_type == DB_TYPE_MYISAM && wsrep_check_mode(WSREP_MODE_REPLICATE_MYISAM)) ||
14491456
(db_type == DB_TYPE_ARIA && wsrep_check_mode(WSREP_MODE_REPLICATE_ARIA)));
1450-
TABLE *tbl= tables->table;
14511457

14521458
if (replicate)
14531459
{

0 commit comments

Comments
 (0)