1-- source include/have_multi_ndb.inc
2-- source include/have_binlog_format_mixed_or_row.inc
3# We are using some debug-only features in this test
4--source include/have_debug.inc
5# Test terminates mysqld which causes valgrind warnings
6--source include/not_valgrind.inc
7# Ignore any mysqld failure reporting
8--source include/not_crashrep.inc
9
10connection server1;
11# Find NodeId of the mysqld we are connected to:
12--let $node_id= `SHOW STATUS LIKE 'Ndb_cluster_node_id'`
13--let $node_id= `SELECT SUBSTRING('$node_id', 20)+0`
14--disable_query_log
15call mtr.add_suppression("cluster disconnect An incident event");
16--enable_query_log
17
18connection server2;
19# Find NodeId2 of 'server2' we are connected to:
20--let $node_id2= `SHOW STATUS LIKE 'Ndb_cluster_node_id'`
21--let $node_id2= `SELECT SUBSTRING('$node_id2', 20)+0`
22
23# Ignore server shutdown/startup failure
24--disable_query_log
25call mtr.add_suppression("Failed to setup binlog");
26call mtr.add_suppression("Distribution of CREATE TABLE");
27call mtr.add_suppression("Server shutdown in progress");
28call mtr.add_suppression("cluster disconnect An incident event");
29call mtr.add_suppression("Failed setting up binlogging");
30call mtr.add_suppression("mysqld startup an incident event");
31call mtr.add_suppression("Failed to release global schema lock");
32--enable_query_log
33
34#
35# 1 create a table
36# 2 Setup error insert on MySQLD2
37# 3 Disconnect MySQLD2 using DUMP code, causing Binlog re-init
38# 4 Observe MySQLD2 fail, then restart (and succeed)
39#
40
41connection server1;
42use test;
43
44create table t1 (a int primary key) engine=ndb;
45insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
46
47connection server2;
48disable_query_log;
49let $debug_saved = `select @@global.debug`;
50set global debug='-d'; # Switch DEBUG/TRACING OFF
51set global debug='+d,ndb_binlog_fail_setup';
52enable_query_log;
53
54--echo Prepare for Server2 to fail
55connection server2;
56# Find NodeId2 of 'server2' we are connected to:
57--let $node_id2= `SHOW STATUS LIKE 'Ndb_cluster_node_id'`
58--let $node_id2= `SELECT SUBSTRING('$node_id2', 20)+0`
59
60#
61# Some magic for MTR to allow failure, taken from include/restart_mysqld.inc
62#
63--let $_server_id= `SELECT @@server_id`
64--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.1.expect
65
66--exec echo "wait" > $_expect_file_name
67#
68# /end magic part 1
69#
70
71#
72# Cause data nodes to disconnect all API nodes
73# Each API will setup binlog again
74# MySQLD2 will get stuck and restart
75#
76
77--exec $NDB_MGM --no-defaults -e "ALL DUMP 900 $node_id" > $NDB_TOOLS_OUTPUT
78--exec $NDB_MGM --no-defaults -e "ALL DUMP 900 $node_id2" > $NDB_TOOLS_OUTPUT
79
80#connection server1;
81#--echo Wait for 'server1' binlog rotate to indicate disconnect
82#--let $wait_binlog_event= binlog.000002
83#--source include/wait_for_binlog_event.inc
84
85connection server2;
86--echo Wait for 'server2' binlog rotate to indicate disconnect
87--let $wait_binlog_event= binlog.000002
88--source include/wait_for_binlog_event.inc
89
90connection server1;
91--source include/ndb_not_readonly.inc
92insert into t1 values (11);
93
94--echo Give 'server2' some time to start, and fail, a binlog_setup
95sleep 2;
96
97--echo Wait for Server2 to fail
98connection server2;
99--source include/wait_until_disconnected.inc
100
101--echo Server2 failed as expected
102
103#
104# More magic from include/restart_mysqld.inc
105#
106--exec echo "restart" > $_expect_file_name
107
108--enable_reconnect
109--source include/wait_until_connected_again.inc
110--disable_reconnect
111#
112# /end magic part 2
113#
114
115connection server1;
116insert into t1 values (10);
117drop table test.t1;
118
119connection server2;
120--echo Wait for 'server2' to complete setup and get out of read-only mode
121--source include/ndb_not_readonly.inc
122--remove_file $NDB_TOOLS_OUTPUT
123
124#
125# 1 Setup error insert on MySQLD2
126# 2 create a table on MySQLD1
127# 3 Observe MySQLD2 fail, then restart (and succeed)
128#
129
130--echo Prepare for Server2 to fail
131--connection server2
132#
133# Some magic for MTR to allow failure, taken from include/restart_mysqld.inc
134#
135--let $_server_id= `SELECT @@server_id`
136--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.1.expect
137
138--exec echo "wait" > $_expect_file_name
139#
140# /end magic part 1
141#
142
143--connection server2
144set global debug='-d'; # Switch DEBUG/TRACING OFF
145set global debug='+d,ndb_binlog_fail_setup';
146
147--connection server1
148use test;
149--disable_warnings
150create table t1 (a int primary key) engine=ndb;
151insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
152
153--echo Wait for Server2 to fail
154--connection server2
155--source include/wait_until_disconnected.inc
156
157--echo Server2 failed as expected
158--enable_warnings
159
160#
161# More magic from include/restart_mysqld.inc
162#
163--exec echo "restart" > $_expect_file_name
164
165--enable_reconnect
166--source include/wait_until_connected_again.inc
167--disable_reconnect
168#
169# /end magic part 2
170#
171
172--source include/ndb_not_readonly.inc
173insert into t1 values (10);
174
175--connection server1
176--source include/ndb_not_readonly.inc
177insert into t1 values (11);
178drop table t1;
179
180--connection server2
181disable_query_log;
182set global debug='+d'; # Switch DEBUG/TRACING ON
183eval set global debug= '$debug_saved';
184enable_query_log;
185