Skip to content

Commit 3228c08

Browse files
janlindstromsysprg
authored andcommitted
MDEV-22063 : Assertion `0' failed in wsrep::transaction::before_rollback
Problem was that REPLACE was using consistency check that started TOI and we tried to rollback it. Do not use wsrep_before_rollback and wsrep_after_rollback if we are runing consistency check because no writeset keys are in that case added. Do not allow consistency check usage if table storage for target table is not InnoDB, instead give warning. REPLACE|SELECT INTO ... SELECT will use now TOI if table storage for target table is not InnoDB to maintain consistency between galera nodes. Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
1 parent 112eb14 commit 3228c08

File tree

6 files changed

+515
-14
lines changed

6 files changed

+515
-14
lines changed
Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
connection node_2;
22
connection node_1;
3+
SET GLOBAL wsrep_replicate_myisam=ON;
34
CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM;
45
INSERT INTO t1 VALUES (1);
56
INSERT INTO t1 VALUES (2), (3);
@@ -14,14 +15,37 @@ UPDATE t1 SET f1 = 9;
1415
UPDATE t2 SET f1 = 9 WHERE f1 = 1;
1516
DELETE FROM t1 WHERE f1 = 9;
1617
DELETE FROM t2 WHERE f1 = 9;
18+
SELECT * FROM t1 ORDER BY f1;
19+
f1
20+
SELECT * FROM t2 ORDER BY f1;
21+
f1
22+
2
23+
3
24+
4
25+
5
26+
6
27+
connection node_2;
28+
SELECT * FROM t1 ORDER BY f1;
29+
f1
30+
SELECT * FROM t2 ORDER BY f1;
31+
f1
32+
2
33+
3
34+
4
35+
5
36+
6
1737
TRUNCATE TABLE t1;
18-
TRUNCATE TABLE t1;
38+
TRUNCATE TABLE t2;
39+
SELECT * FROM t1 ORDER BY f1;
40+
f1
41+
SELECT * FROM t2 ORDER BY f1;
42+
f1
1943
connection node_2;
20-
SELECT COUNT(*) = 0 FROM t1;
21-
COUNT(*) = 0
22-
1
23-
SELECT COUNT(*) = 0 FROM t2;
24-
COUNT(*) = 0
25-
1
44+
SELECT * FROM t1 ORDER BY f1;
45+
f1
46+
SELECT * FROM t2 ORDER BY f1;
47+
f1
48+
connection node_1;
49+
SET GLOBAL wsrep_replicate_myisam=OFF;
2650
DROP TABLE t1;
2751
DROP TABLE t2;
Lines changed: 242 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,242 @@
1+
connection node_2;
2+
connection node_1;
3+
# Case 1 CREATE SEQUENCE with no NOCACHE
4+
CREATE SEQUENCE s ENGINE=InnoDB;
5+
ERROR 42000: This version of MariaDB doesn't yet support 'CACHE without INCREMENT BY 0 in Galera cluster'
6+
CREATE SEQUENCE s NOCACHE ENGINE=InnoDB;
7+
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
8+
START TRANSACTION;
9+
REPLACE INTO s VALUES (1,1,9223372036854775806,1,1,1000,0,0);
10+
OPTIMIZE TABLE t1;
11+
Table Op Msg_type Msg_text
12+
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
13+
test.t1 optimize status OK
14+
SELECT * FROM t1;
15+
a
16+
SELECT * FROM s;
17+
next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
18+
1 1 9223372036854775806 1 1 1000 0 0
19+
connection node_2;
20+
SELECT * FROM t1;
21+
a
22+
SELECT * FROM s;
23+
next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
24+
1 1 9223372036854775806 1 1 1000 0 0
25+
connection node_1;
26+
DROP TABLE t1;
27+
DROP SEQUENCE s;
28+
# Case 2 REPLACE INTO ... SELECT with error
29+
CREATE TABLE t (id INT KEY,a YEAR,INDEX (id,a)) engine=innodb;
30+
REPLACE INTO t (id,a)SELECT /*!99997 */ 1;
31+
ERROR 21S01: Column count doesn't match value count at row 1
32+
REPLACE INTO t (id,a)SELECT /*!99997 */ 1,2;
33+
SELECT * FROM t;
34+
id a
35+
1 2002
36+
CREATE TABLE t2 (id INT KEY,a YEAR,INDEX (id,a)) engine=myisam;
37+
REPLACE INTO t2 (id,a)SELECT /*!99997 */ 1;
38+
ERROR 21S01: Column count doesn't match value count at row 1
39+
REPLACE INTO t2 (id,a)SELECT /*!99997 */ 1,2;
40+
Warnings:
41+
Warning 138 Galera cluster does support consistency check only for InnoDB tables.
42+
SELECT * FROM t2;
43+
id a
44+
1 2002
45+
CREATE TABLE t3 (id INT KEY,a YEAR,INDEX (id,a)) engine=aria;
46+
REPLACE INTO t3 (id,a)SELECT /*!99997 */ 1;
47+
ERROR 21S01: Column count doesn't match value count at row 1
48+
REPLACE INTO t3 (id,a)SELECT /*!99997 */ 1,2;
49+
Warnings:
50+
Warning 138 Galera cluster does support consistency check only for InnoDB tables.
51+
SELECT * FROM t3;
52+
id a
53+
1 2002
54+
connection node_2;
55+
SELECT * FROM t;
56+
id a
57+
1 2002
58+
SELECT * FROM t2;
59+
id a
60+
1 2002
61+
SELECT * FROM t3;
62+
id a
63+
1 2002
64+
connection node_1;
65+
DROP TABLE t,t2,t3;
66+
# Bigger REPLACE ... AS SELECT test
67+
SET GLOBAL wsrep_replicate_myisam=ON;
68+
CREATE TABLE t1(id int not null primary key ,b int) ENGINE=InnoDB;
69+
CREATE TABLE t2(id int not null primary key ,b int) ENGINE=MyISAM;
70+
CREATE TABLE t3(id int not null primary key ,b int) ENGINE=Aria;
71+
CREATE TABLE t4(id int not null primary key ,b int) ENGINE=InnoDB;
72+
CREATE TABLE t5(id int not null primary key ,b int) ENGINE=InnoDB;
73+
CREATE TABLE t6(id int not null primary key ,b int) ENGINE=InnoDB;
74+
CREATE TABLE t7(id int not null primary key ,b int) ENGINE=MyISAM;
75+
CREATE TABLE t8(id int not null primary key ,b int) ENGINE=Aria;
76+
INSERT INTO t1(id) SELECT seq FROM seq_1_to_1000;
77+
INSERT INTO t2(id) SELECT seq FROM seq_1_to_1000;
78+
INSERT INTO t3(id) SELECT seq FROM seq_1_to_1000;
79+
REPLACE INTO t4 SELECT * FROM t1;
80+
REPLACE INTO t5 SELECT * FROM t2;
81+
REPLACE INTO t6 SELECT * FROM t3;
82+
REPLACE INTO t7 SELECT * FROM t2;
83+
REPLACE INTO t8 SELECT * FROM t3;
84+
SELECT COUNT(*) AS EXPECT_1000 FROM t1;
85+
EXPECT_1000
86+
1000
87+
SELECT COUNT(*) AS EXPECT_1000 FROM t2;
88+
EXPECT_1000
89+
1000
90+
SELECT COUNT(*) AS EXPECT_1000 FROM t3;
91+
EXPECT_1000
92+
1000
93+
SELECT COUNT(*) AS EXPECT_1000 FROM t4;
94+
EXPECT_1000
95+
1000
96+
SELECT COUNT(*) AS EXPECT_1000 FROM t5;
97+
EXPECT_1000
98+
1000
99+
SELECT COUNT(*) AS EXPECT_1000 FROM t6;
100+
EXPECT_1000
101+
1000
102+
SELECT COUNT(*) AS EXPECT_1000 FROM t7;
103+
EXPECT_1000
104+
1000
105+
SELECT COUNT(*) AS EXPECT_1000 FROM t8;
106+
EXPECT_1000
107+
1000
108+
connection node_2;
109+
SELECT COUNT(*) AS EXPECT_1000 FROM t1;
110+
EXPECT_1000
111+
1000
112+
SELECT COUNT(*) AS EXPECT_1000 FROM t2;
113+
EXPECT_1000
114+
1000
115+
SELECT COUNT(*) AS EXPECT_1000 FROM t3;
116+
EXPECT_1000
117+
1000
118+
SELECT COUNT(*) AS EXPECT_1000 FROM t4;
119+
EXPECT_1000
120+
1000
121+
SELECT COUNT(*) AS EXPECT_1000 FROM t5;
122+
EXPECT_1000
123+
1000
124+
SELECT COUNT(*) AS EXPECT_1000 FROM t6;
125+
EXPECT_1000
126+
1000
127+
SELECT COUNT(*) AS EXPECT_1000 FROM t7;
128+
EXPECT_1000
129+
1000
130+
SELECT COUNT(*) AS EXPECT_1000 FROM t8;
131+
EXPECT_1000
132+
1000
133+
connection node_1;
134+
DROP TABLE t1,t2,t3,t4,t5,t6,t7,t8;
135+
# Bigger INSERT INTO ... SELECT test
136+
CREATE TABLE t1(id int not null primary key ,b int) ENGINE=InnoDB;
137+
CREATE TABLE t2(id int not null primary key ,b int) ENGINE=MyISAM;
138+
CREATE TABLE t3(id int not null primary key ,b int) ENGINE=Aria;
139+
CREATE TABLE t4(id int not null primary key ,b int) ENGINE=InnoDB;
140+
CREATE TABLE t5(id int not null primary key ,b int) ENGINE=InnoDB;
141+
CREATE TABLE t6(id int not null primary key ,b int) ENGINE=InnoDB;
142+
CREATE TABLE t7(id int not null primary key ,b int) ENGINE=MyISAM;
143+
CREATE TABLE t8(id int not null primary key ,b int) ENGINE=Aria;
144+
INSERT INTO t1(id) SELECT seq FROM seq_1_to_1000;
145+
INSERT INTO t2(id) SELECT seq FROM seq_1_to_1000;
146+
INSERT INTO t3(id) SELECT seq FROM seq_1_to_1000;
147+
INSERT INTO t4 SELECT * FROM t1;
148+
INSERT INTO t5 SELECT * FROM t2;
149+
INSERT INTO t6 SELECT * FROM t3;
150+
INSERT INTO t7 SELECT * FROM t2;
151+
INSERT INTO t8 SELECT * FROM t3;
152+
SELECT COUNT(*) AS EXPECT_1000 FROM t1;
153+
EXPECT_1000
154+
1000
155+
SELECT COUNT(*) AS EXPECT_1000 FROM t2;
156+
EXPECT_1000
157+
1000
158+
SELECT COUNT(*) AS EXPECT_1000 FROM t3;
159+
EXPECT_1000
160+
1000
161+
SELECT COUNT(*) AS EXPECT_1000 FROM t4;
162+
EXPECT_1000
163+
1000
164+
SELECT COUNT(*) AS EXPECT_1000 FROM t5;
165+
EXPECT_1000
166+
1000
167+
SELECT COUNT(*) AS EXPECT_1000 FROM t6;
168+
EXPECT_1000
169+
1000
170+
SELECT COUNT(*) AS EXPECT_1000 FROM t7;
171+
EXPECT_1000
172+
1000
173+
SELECT COUNT(*) AS EXPECT_1000 FROM t8;
174+
EXPECT_1000
175+
1000
176+
connection node_2;
177+
SELECT COUNT(*) AS EXPECT_1000 FROM t1;
178+
EXPECT_1000
179+
1000
180+
SELECT COUNT(*) AS EXPECT_1000 FROM t2;
181+
EXPECT_1000
182+
1000
183+
SELECT COUNT(*) AS EXPECT_1000 FROM t3;
184+
EXPECT_1000
185+
1000
186+
SELECT COUNT(*) AS EXPECT_1000 FROM t4;
187+
EXPECT_1000
188+
1000
189+
SELECT COUNT(*) AS EXPECT_1000 FROM t5;
190+
EXPECT_1000
191+
1000
192+
SELECT COUNT(*) AS EXPECT_1000 FROM t6;
193+
EXPECT_1000
194+
1000
195+
SELECT COUNT(*) AS EXPECT_1000 FROM t7;
196+
EXPECT_1000
197+
1000
198+
SELECT COUNT(*) AS EXPECT_1000 FROM t8;
199+
EXPECT_1000
200+
1000
201+
connection node_1;
202+
DROP TABLE t1,t2,t3,t4,t5,t6,t7,t8;
203+
CREATE TABLE t1(pk int not null primary key) engine=innodb;
204+
INSERT INTO t1 values (1),(2),(3),(4);
205+
CREATE VIEW view_t1 AS SELECT * FROM t1;
206+
INSERT INTO view_t1 VALUES (5);
207+
SELECT * FROM t1;
208+
pk
209+
1
210+
2
211+
3
212+
4
213+
5
214+
DROP TABLE t1;
215+
DROP VIEW view_t1;
216+
CREATE TABLE t1(pk int not null primary key) engine=myisam;
217+
INSERT INTO t1 values (1),(2),(3),(4);
218+
CREATE VIEW view_t1 AS SELECT * FROM t1;
219+
INSERT INTO view_t1 VALUES (5);
220+
SELECT * FROM t1;
221+
pk
222+
1
223+
2
224+
3
225+
4
226+
5
227+
DROP TABLE t1;
228+
DROP VIEW view_t1;
229+
CREATE TABLE t1(pk int not null primary key) engine=aria;
230+
INSERT INTO t1 values (1),(2),(3),(4);
231+
CREATE VIEW view_t1 AS SELECT * FROM t1;
232+
INSERT INTO view_t1 VALUES (5);
233+
SELECT * FROM t1;
234+
pk
235+
1
236+
2
237+
3
238+
4
239+
5
240+
DROP TABLE t1;
241+
DROP VIEW view_t1;
242+
SET GLOBAL wsrep_replicate_myisam=OFF;

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

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,24 @@
22
--source include/have_innodb.inc
33

44
#
5-
# This tests simple autocommit replication of MyISAM tables. No updates arrive on the slave.
5+
# This tests simple autocommit replication of MyISAM tables.
66
#
77

8+
SET GLOBAL wsrep_replicate_myisam=ON;
9+
810
# Without a PK
911

1012
CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM;
1113

1214
INSERT INTO t1 VALUES (1);
1315
INSERT INTO t1 VALUES (2), (3);
16+
# This is TOI
1417
INSERT INTO t1 SELECT 4 FROM DUAL UNION ALL SELECT 5 FROM DUAL;
1518

1619
CREATE TABLE t2 (f1 INTEGER PRIMARY KEY) ENGINE=MyISAM;
1720
INSERT INTO t2 VALUES (1);
1821
INSERT INTO t2 VALUES (2), (3);
22+
# This is TOI
1923
INSERT INTO t2 SELECT 4 FROM DUAL UNION ALL SELECT 5 FROM DUAL;
2024

2125
# Error
@@ -32,14 +36,26 @@ UPDATE t2 SET f1 = 9 WHERE f1 = 1;
3236
DELETE FROM t1 WHERE f1 = 9;
3337
DELETE FROM t2 WHERE f1 = 9;
3438

39+
SELECT * FROM t1 ORDER BY f1;
40+
SELECT * FROM t2 ORDER BY f1;
41+
42+
--connection node_2
43+
SELECT * FROM t1 ORDER BY f1;
44+
SELECT * FROM t2 ORDER BY f1;
45+
3546
# TRUNCATE
3647

3748
TRUNCATE TABLE t1;
38-
TRUNCATE TABLE t1;
49+
TRUNCATE TABLE t2;
50+
51+
SELECT * FROM t1 ORDER BY f1;
52+
SELECT * FROM t2 ORDER BY f1;
3953

4054
--connection node_2
41-
SELECT COUNT(*) = 0 FROM t1;
42-
SELECT COUNT(*) = 0 FROM t2;
55+
SELECT * FROM t1 ORDER BY f1;
56+
SELECT * FROM t2 ORDER BY f1;
4357

58+
--connection node_1
59+
SET GLOBAL wsrep_replicate_myisam=OFF;
4460
DROP TABLE t1;
4561
DROP TABLE t2;

0 commit comments

Comments
 (0)