Debian Codegraph @

mysql-test/suite/ndb_ddl/schema_dist_client_abort.test

raw
1 --source include/have_debug.inc
2 # This test crashes MySQL Server on purpose.
3 --source include/not_valgrind.inc
4 --source include/not_crashrep.inc
5
6 # Connect to all
7 --source connect.inc
8
9 --echo #
10 --echo # Test client abort of schema operation
11 --echo #
12
13
14 --echo # Setup to trigger the client to detect that schema
15 --echo # distribution is no longer ready
16 set GLOBAL debug="+d,ndb_schema_dist_client_not_ready";
17
18 # Supress warning which is written to log when client detect not ready
19 --disable_query_log ONCE
20 call mtr.add_suppression("Distribution of .* not ready!");
21
22 --echo # Do schema operation which will cause the client to abort its
23 --echo # schema operation
24 --replace_regex /Node [0-9]+:/Node <nodeid>/
25 CREATE TABLE t1(
26 a int primary key
27 ) engine = NDB;
28
29 # Remove debug setup
30 set GLOBAL debug="-d,ndb_schema_dist_client_not_ready";
31
32 # Wait until ready again
33 --source include/ndb_not_readonly.inc
34
35 --echo # Verify that there are no leftover entries in
36 --echo # mysql.ndb_schema_result table
37 --exec $NDB_SELECT_ALL -d mysql ndb_schema_result
38
39 --echo # Cleanup
40 DROP TABLE t1;
41
42 --echo #
43 --echo # Bug#30684839 SCHEMA DISTRIBUTION ABORT IS NOT HANDLED PROPERLY SOMETIMES
44 --echo #
45
46 --echo # Setup
47 CREATE TABLE t1 (
48 a int primary key
49 ) engine NDB;
50
51 --echo # Setup to trigger the client to detect that it was killed before
52 --echo # starting the schema distribution
53 set GLOBAL debug="+d,ndb_schema_dist_client_killed_before_write";
54
55 # Supress warning which is written to log when distribution is aborted
56 --disable_query_log ONCE
57 call mtr.add_suppression("Distribution of .* aborted!");
58
59 # Do schema operations which will cause the client to detect it
60 # has been killed before the distribution starts and thus
61 # aborting the distribution
62
63 --echo # CREATE TABLE should abort the distribution and fail
64 --error ER_CANT_CREATE_TABLE
65 CREATE TABLE t2 (
66 a int primary key
67 ) engine NDB;
68
69 --echo # ALTER TABLE should abort the distribution but succeed with warnings
70
71 # Supress error which is written to log when distribution is aborted
72 --disable_query_log ONCE
73 call mtr.add_suppression("Failed to distribute 'ALTER TABLE t1'");
74
75 ALTER TABLE t1 ADD COLUMN b int, algorithm = COPY;
76
77 --echo # Remove debug setup
78 set GLOBAL debug="-d,ndb_schema_dist_client_killed_before_write";
79
80 DROP TABLE t1;
81
82 --echo # Setup to trigger the client to detect that it was killed while
83 --echo # waiting for schema distribuiton to complete
84 set GLOBAL debug="+d,ndb_schema_dist_client_killed_after_write";
85
86 # Supress warning which is written to log when client is killed
87 --disable_query_log ONCE
88 call mtr.add_suppression("Distribution of .* client killed .*!");
89
90 --echo # Do schema operation which will cause the client to detect it
91 --echo # has been killed but will proceed to completion nevertheless
92 CREATE TABLE t1(
93 a int primary key
94 ) engine = NDB;
95
96 # Remove debug setup
97 set GLOBAL debug="-d,ndb_schema_dist_client_killed_after_write";
98
99 DROP TABLE t1;
100
101 --echo # Shutdown the MySQL Server when the coordinator is waiting on the
102 --echo # participants and verify that they are handled smoothly
103
104 --echo # Skip sending ack from participant mysqld2 to make the coordinator wait
105 --connection mysqld2
106 set GLOBAL debug="+d,ndb_skip_participant_ack";
107 --connection mysqld1
108
109 --echo # Send the CREATE TABLE query to mysqld1
110 # Create an alternate connection and send the DDL for execution, as the
111 # connection will be blocked until the DDL returns. The original connection
112 # is needed for shutting down the server. Also note that 'reap' is never
113 # called for this 'send' as this connection will be lost after restart.
114 --connect(mysqld1_alt,127.0.0.1,root,,test,$MYSQLD_PORT_1)
115 --send
116 CREATE TABLE t1 (
117 a INT PRIMARY KEY
118 ) ENGINE = NDB;
119
120 --echo # Wait for the DDL to be logged in ndb_schema table
121 # This is ensured by waiting for the table to appear in
122 # another mysqld that is not the coordinator
123 --connection mysqld3
124 let $wait_condition= SELECT COUNT(*)
125 FROM INFORMATION_SCHEMA.TABLES
126 WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 't1';
127 --source include/wait_condition_or_abort.inc
128 --connection mysqld1
129
130 --echo # The coordinator is now waiting for the participants
131 --echo # Restart it and verify that it shuts down without any issues
132 let $mysqld_name=mysqld.1.1;
133 --source include/restart_mysqld.inc
134
135 # Remove debug setup
136 --connection mysqld2
137 set GLOBAL debug="-d,ndb_skip_participant_ack";
138 --connection mysqld1
139
140 # Wait until ready again
141 --source include/ndb_not_readonly.inc
142
143 --echo # Verify that there are no leftover entries in
144 --echo # mysql.ndb_schema_result table
145 --exec $NDB_SELECT_ALL -d mysql ndb_schema_result
146
147 --echo # Verify table exists
148 show create table t1;
149
150 --echo # Cleanup
151 DROP TABLE t1;