Debian Codegraph @

mysql-test/suite/ndb/t/ndb_wait_until_ready.test

raw
1 -- source include/have_ndb.inc
2 -- source include/have_multi_ndb.inc
3
4 # Test uses a 4 node configuration with
5 # ndbd using nodeid 1-4, mgmd 5, first mysqld 6 and second mysqld 7
6
7 # Check that there are 4 connections from second mysqld
8 connection server1;
9 let $wait_condition = select count(*) = 4
10 from ndbinfo.transporters
11 where remote_node_id = 7 and status='CONNECTED';
12 --source include/wait_condition.inc
13
14 --echo # Restart mysqld with all data nodes started
15 connection server2;
16
17 # Ignore the warning generated by ndbcluster's binlog thread
18 # when mysqld is restarted
19 --disable_query_log ONCE
20 call mtr.add_suppression("mysqld startup An incident event has been written");
21
22 let $start_time = `select now()`;
23 let $mysqld_name=mysqld.2.1;
24 --source include/restart_mysqld.inc
25 let $mysqld_restart_time_full_cluster= `select timestampdiff(second, '$start_time', now())`;
26 #echo $mysqld_restart_time_full_cluster;
27
28 --echo # Check that there are still 4 connections from second mysqld
29 connection server1;
30 let $wait_condition = select count(*) = 4
31 from ndbinfo.transporters
32 where remote_node_id = 7 and status='CONNECTED';
33 --source include/wait_condition.inc
34
35 ## Calculate a reasonable limit for restart time for mysqld with partial cluster
36 ## It should take about the same time as with full cluster, but also depends
37 ## on what else runs on the machine at the time. Use average between mysqld
38 ## restart time with full cluster (see above) and maximal time according to
39 ## configuration.
40 ## Could of course just skip this and just check the number of connections
41 ## after restart.
42 ## Note also that in normal case the main part of restart time is not spent
43 ## waiting for db nodes.
44 let $mysqld_restart_time_partial_cluster_limit =
45 `select $mysqld_restart_time_full_cluster + (@@ndb_wait_connected / 2)`;
46 #echo $mysqld_restart_time_partial_cluster_limit;
47
48 # Stop two data nodes, one with node group, one without
49 --exec $NDB_MGM --execute "2 restart -n"
50 --exec $NDB_MGM --execute "4 restart -n -a"
51
52 --echo # Check that there are only _2_ connections from second mysqld
53 connection server1;
54 let $wait_condition = select count(*) = 2
55 from ndbinfo.transporters
56 where remote_node_id = 7 and status='CONNECTED';
57 --source include/wait_condition.inc
58
59 --echo # Restart one mysqld with 2 data nodes down and check how long it took
60 connection server2;
61 let $start_time = `select now()`;
62 let $mysqld_name=mysqld.2.1;
63 --source include/restart_mysqld.inc
64 let $mysqld_restart_time_partial_cluster= `select timestampdiff(second, '$start_time', now())`;
65 #echo $mysqld_restart_time_partial_cluster;
66
67 if (`select $mysqld_restart_time_partial_cluster >= $mysqld_restart_time_partial_cluster_limit`)
68 {
69 select * from ndbinfo.transporters;
70 select now();
71 echo mysqld_restart_time_full_cluster: $mysqld_restart_time_full_cluster;
72 echo mysqld_restart_time_partial_cluster: $mysqld_restart_time_partial_cluster;
73 echo mysqld_restart_time_partial_cluster_limit: $mysqld_restart_time_partial_cluster_limit;
74 select @@ndb_wait_connected;
75 -- die Restart took longer time then expected, indicates either bug or extreme load on test machine.
76 }
77
78 --echo # Check that there are 2 connections from second mysqld
79 connection server1;
80 let $wait_condition = select count(*) = 2
81 from ndbinfo.transporters
82 where remote_node_id = 7 and status='CONNECTED';
83 --source include/wait_condition.inc
84
85 --echo # Start all data nodes again.
86 --exec $NDB_MGM --execute "2 start"
87 --exec $NDB_MGM --execute "4 start"
88 --exec $NDB_WAITER --wait-nodes=2,4
89
90 --echo # Check that there are again 4 connections from second mysqld
91 connection server1;
92 let $wait_condition = select count(*) = 4
93 from ndbinfo.transporters
94 where remote_node_id = 7 and status='CONNECTED';
95 # Would really just want to wait for one api data node heart beat interval (1.5s)
96 # to verify that newly started data nodes are quickly connected by api node.
97 # But since mtr often runs in overloaded hosts a longer timeout (6s) is used.
98 let $wait_timeout = 6;
99 --source include/wait_condition.inc