summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/galera/t/galera_admin.test
blob: d630af0025b7f1e13b25354436684de98c50897b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#
# Test that various admin commands from sql_admin.cc
# Currently, REPAIR, OPTIMIZE and ANALYZE are tested.
# Jira: PXC-390
#

--source include/galera_cluster.inc
--source include/have_aria.inc

--disable_warnings
DROP TABLE IF EXISTS t1, t2;
DROP TABLE IF EXISTS x1, x2;
--enable_warnings

--connection node_1
CREATE TABLE t1 (f1 INTEGER);
CREATE TABLE t2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER);
SET GLOBAL wsrep_mode = REPLICATE_MYISAM;
CREATE TABLE x1 (f1 INTEGER) ENGINE=MyISAM;
CREATE TABLE x2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
INSERT INTO x1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
INSERT INTO t2 (f2) SELECT 1 FROM t1 AS a1, t1 AS a2, t1 AS a3, t1 AS a4;
INSERT INTO x2 (f2) VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);

# Wait until all the data from t2 has been replicated
--connection node_2
--let $wait_condition = SELECT COUNT(*) = 10 FROM x1;
--source include/wait_condition.inc
--let $wait_condition = SELECT COUNT(*) = 10 FROM x2;
--source include/wait_condition.inc
--let $wait_condition = SELECT COUNT(*) = 10 FROM t1;
--source include/wait_condition.inc
--let $wait_condition = SELECT COUNT(*) = 10000 FROM t2;
--source include/wait_condition.inc

--echo # ANALYZE test
--connection node_2
--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`

--connection node_1
ANALYZE TABLE t1, t2;

--connection node_2
--let $wait_condition = SELECT VARIABLE_VALUE = $wsrep_last_committed_before + 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'
--source include/wait_condition.inc

--echo # OPTIMIZE test
--connection node_2
--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`

--connection node_1
OPTIMIZE TABLE t1, t2;

--connection node_2
--let $wait_condition = SELECT VARIABLE_VALUE >= $wsrep_last_committed_before + 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'
--source include/wait_condition.inc

--echo # REPAIR test
--connection node_2
--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`

--connection node_1
REPAIR TABLE x1, x2;

--connection node_2
--let $wait_condition = SELECT VARIABLE_VALUE >= $wsrep_last_committed_before + 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'
--source include/wait_condition.inc

--connection node_2
SELECT COUNT(*) = 10 FROM t1;
SELECT COUNT(*) = 10 FROM x1;
SELECT COUNT(*) = 10000 FROM t2;
SELECT COUNT(*) = 10 FROM x2;

--connection node_1
DROP TABLE t1, t2;
DROP TABLE x1, x2;

--echo #
--echo # ARIA
--echo #
--connection node_1
CREATE TABLE t1 (f1 INTEGER);
CREATE TABLE t2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER);
SET GLOBAL wsrep_mode = REPLICATE_ARIA;
CREATE TABLE x1 (f1 INTEGER) ENGINE=ARIA;
CREATE TABLE x2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=ARIA;
INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
INSERT INTO x1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
INSERT INTO t2 (f2) SELECT 1 FROM t1 AS a1, t1 AS a2, t1 AS a3, t1 AS a4;
INSERT INTO x2 (f2) VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);

# Wait until all the data from t2 has been replicated
--connection node_2
--let $wait_condition = SELECT COUNT(*) = 10 FROM x1;
--source include/wait_condition.inc
--let $wait_condition = SELECT COUNT(*) = 10 FROM x2;
--source include/wait_condition.inc
--let $wait_condition = SELECT COUNT(*) = 10 FROM t1;
--source include/wait_condition.inc
--let $wait_condition = SELECT COUNT(*) = 10000 FROM t2;
--source include/wait_condition.inc

--echo # ANALYZE test
--connection node_2
--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`

--connection node_1
ANALYZE TABLE t1, t2;

--connection node_2
--let $wait_condition = SELECT VARIABLE_VALUE = $wsrep_last_committed_before + 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'
--source include/wait_condition.inc

--echo # OPTIMIZE test
--connection node_2
--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`

--connection node_1
OPTIMIZE TABLE t1, t2;

--connection node_2
--let $wait_condition = SELECT VARIABLE_VALUE >= $wsrep_last_committed_before + 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'
--source include/wait_condition.inc

--echo # REPAIR test
--connection node_2
--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`

--connection node_1
REPAIR TABLE x1, x2;

--connection node_2
--let $wait_condition = SELECT VARIABLE_VALUE >= $wsrep_last_committed_before + 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'
--source include/wait_condition.inc

--connection node_2
SELECT COUNT(*) = 10 FROM t1;
SELECT COUNT(*) = 10 FROM x1;
SELECT COUNT(*) = 10000 FROM t2;
SELECT COUNT(*) = 10 FROM x2;

--connection node_1
DROP TABLE t1, t2;
DROP TABLE x1, x2;

--disable_query_log
SET GLOBAL wsrep_mode = DEFAULT;
--enable_query_log