Skip to content

Commit 59f3285

Browse files
philip-galeramariadb-SachinSetiya
authored andcommitted
Galera MTR Tests: Test for MW-329 Fix incorrect affected rows count after replay
1 parent ff74262 commit 59f3285

File tree

2 files changed

+141
-0
lines changed

2 files changed

+141
-0
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
CREATE TABLE t1 (f1 INTEGER, f2 CHAR(20) DEFAULT 'abc') ENGINE=InnoDB;
2+
INSERT INTO t1 (f1) VALUES (1),(65535);
3+
FLUSH STATUS;
4+
SELECT VARIABLE_VALUE = 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays';
5+
VARIABLE_VALUE = 0
6+
1
7+
CREATE PROCEDURE proc_insert ()
8+
BEGIN
9+
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
10+
SET SESSION wsrep_sync_wait = 0;
11+
WHILE 1 DO
12+
INSERT INTO t1 (f1) VALUES (FLOOR( 1 + RAND( ) * 65535 ));
13+
END WHILE;
14+
END|
15+
CALL proc_insert();;
16+
SELECT ROW_COUNT() > 0;
17+
ROW_COUNT() > 0
18+
1
19+
SELECT FOUND_ROWS() > 0;
20+
FOUND_ROWS() > 0
21+
1
22+
SELECT ROW_COUNT() > 0;
23+
ROW_COUNT() > 0
24+
1
25+
SELECT FOUND_ROWS() > 0;
26+
FOUND_ROWS() > 0
27+
1
28+
SELECT ROW_COUNT() > 0;
29+
ROW_COUNT() > 0
30+
1
31+
SELECT FOUND_ROWS() > 0;
32+
FOUND_ROWS() > 0
33+
1
34+
SELECT ROW_COUNT() > 0;
35+
ROW_COUNT() > 0
36+
1
37+
SELECT FOUND_ROWS() > 0;
38+
FOUND_ROWS() > 0
39+
1
40+
SELECT ROW_COUNT() > 0;
41+
ROW_COUNT() > 0
42+
1
43+
SELECT FOUND_ROWS() > 0;
44+
FOUND_ROWS() > 0
45+
1
46+
SELECT ROW_COUNT() > 0;
47+
ROW_COUNT() > 0
48+
1
49+
SELECT FOUND_ROWS() > 0;
50+
FOUND_ROWS() > 0
51+
1
52+
SELECT ROW_COUNT() > 0;
53+
ROW_COUNT() > 0
54+
1
55+
SELECT FOUND_ROWS() > 0;
56+
FOUND_ROWS() > 0
57+
1
58+
SELECT ROW_COUNT() > 0;
59+
ROW_COUNT() > 0
60+
1
61+
SELECT FOUND_ROWS() > 0;
62+
FOUND_ROWS() > 0
63+
1
64+
SELECT ROW_COUNT() > 0;
65+
ROW_COUNT() > 0
66+
1
67+
SELECT FOUND_ROWS() > 0;
68+
FOUND_ROWS() > 0
69+
1
70+
SELECT ROW_COUNT() > 0;
71+
ROW_COUNT() > 0
72+
1
73+
SELECT FOUND_ROWS() > 0;
74+
FOUND_ROWS() > 0
75+
1
76+
SELECT VARIABLE_VALUE > 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays';
77+
VARIABLE_VALUE > 0
78+
1
79+
DROP PROCEDURE proc_insert;
80+
DROP TABLE t1;

mysql-test/suite/galera/t/MW-329.test

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#
2+
# #MW-329 Fix incorrect affected rows count after replay
3+
#
4+
5+
--source include/galera_cluster.inc
6+
7+
CREATE TABLE t1 (f1 INTEGER, f2 CHAR(20) DEFAULT 'abc') ENGINE=InnoDB;
8+
9+
# We start with a populated table
10+
INSERT INTO t1 (f1) VALUES (1),(65535);
11+
12+
# Clear the wsrep_local_replays counter
13+
14+
FLUSH STATUS;
15+
SELECT VARIABLE_VALUE = 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays';
16+
17+
#
18+
# Run concurrent INSERTs
19+
#
20+
21+
DELIMITER |;
22+
CREATE PROCEDURE proc_insert ()
23+
BEGIN
24+
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
25+
SET SESSION wsrep_sync_wait = 0;
26+
WHILE 1 DO
27+
INSERT INTO t1 (f1) VALUES (FLOOR( 1 + RAND( ) * 65535 ));
28+
END WHILE;
29+
END|
30+
DELIMITER ;|
31+
32+
--connect node_1b, 127.0.0.1, root, , test, $NODE_MYPORT_1
33+
--connection node_1b
34+
--send CALL proc_insert();
35+
36+
#
37+
# Run concurrent UPDATEs. We expect that each UPDATE will report that
38+
# some rows were matched and updated
39+
#
40+
41+
--connection node_2
42+
--let $count = 10
43+
while ($count)
44+
{
45+
--let $signature = `SELECT LEFT(MD5(RAND()), 10)`
46+
--disable_query_log
47+
--eval UPDATE t1 SET f2 = '$signature'
48+
--enable_query_log
49+
SELECT ROW_COUNT() > 0;
50+
SELECT FOUND_ROWS() > 0;
51+
--dec $count
52+
}
53+
54+
#
55+
# Confirm that some transaction replays occurred
56+
#
57+
58+
SELECT VARIABLE_VALUE > 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays';
59+
60+
DROP PROCEDURE proc_insert;
61+
DROP TABLE t1;

0 commit comments

Comments
 (0)