Debian Codegraph @

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

raw
1 --source include/have_ndb.inc
2 --source have_ndb_error_insert.inc
3
4 --echo #
5 --echo # WL-8478 : Undo log speedup - parallel LGMAN applying
6 --echo #
7
8 CREATE LOGFILE GROUP lg_1
9 ADD UNDOFILE 'undo_1.log'
10 INITIAL_SIZE 16M
11 UNDO_BUFFER_SIZE 2M
12 ENGINE NDBCLUSTER;
13
14 ALTER LOGFILE GROUP lg_1
15 ADD UNDOFILE 'undo_2.log'
16 INITIAL_SIZE 12M
17 ENGINE NDBCLUSTER;
18
19 CREATE TABLESPACE ts_1
20 ADD DATAFILE 'data_1.dat'
21 USE LOGFILE GROUP lg_1
22 INITIAL_SIZE 32M
23 ENGINE NDBCLUSTER;
24
25 ALTER TABLESPACE ts_1
26 ADD DATAFILE 'data_2.dat'
27 INITIAL_SIZE 48M;
28
29 CREATE TABLE dt_1 (
30 member_id INT
31 )
32 TABLESPACE ts_1 STORAGE DISK
33 ENGINE NDBCLUSTER;
34
35 let $inserts = 1000;
36 --echo #
37 --echo # Test UNDO_TUP_ALLOC by inserting $inserts * 100 rows in dt_1
38 --echo #
39 --disable_query_log
40 while($inserts > 0)
41 {
42 let $inserted_ok = 0;
43 # Retry query until it succeeds.
44 while(!$inserted_ok)
45 {
46 --error 0,ER_LOCK_WAIT_TIMEOUT
47 INSERT INTO dt_1 VALUES
48 (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),
49 (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),
50 (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),
51 (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),
52 (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),
53 (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),
54 (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),
55 (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),
56 (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),
57 (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
58 if (!$mysql_errno)
59 {
60 # Query suceeded, no more retries
61 let $inserted_ok = 1;
62 }
63 }
64 dec $inserts;
65 }
66 --enable_query_log
67
68 SELECT COUNT(*) AS "Records inserted into dt_1" FROM dt_1;
69
70 CREATE TABLE dt_2 (
71 member_id INT
72 )
73 TABLESPACE ts_1 STORAGE DISK
74 ENGINE NDBCLUSTER;
75
76
77 --echo #
78 --echo # Test UNDO_TUP_FREE by deleting rows with member_id 2 from dt_1
79 --echo #
80 let $deleted_ok = 0;
81 let $retries = 10;
82 # Retry delete until it succeeds or retried too many times
83 --disable_query_log
84 while(!$deleted_ok)
85 {
86 --error 0, ER_LOCK_WAIT_TIMEOUT, ER_GET_TEMPORARY_ERRMSG
87 DELETE FROM dt_1 WHERE member_id = 2;
88 if (!$mysql_errno)
89 {
90 # Query suceeded, no more retries
91 let $deleted_ok = 1;
92 }
93
94 if ($mysql_errno)
95 {
96 # Query failed, check if another retry is allowed
97 dec $retries;
98 if (!$retries)
99 {
100 --die Deleting many tuples in one trans fails after 10 retries.
101 }
102 --sleep 1
103 }
104 }
105 --enable_query_log
106
107 SELECT COUNT(*) AS "Records in dt_1 after delete" FROM dt_1;
108
109 # Check that all records with member_id 2 was deleted (ie. there should be none)
110 if (`SELECT COUNT(*) FROM dt_1 WHERE member_id = 2`)
111 {
112 die failed to delete all records with member_id = 2 from dt_1;
113 }
114
115
116 --echo #
117 --echo # Test UNDO_TUP_UPDATE by updating rows where member_id = 5 in dt_1
118 --echo #
119 let $updated_ok = 0
120 let $retries = 10;
121 # Retry update until it succeeds or retried too many times
122 --disable_query_log
123 while(!$updated_ok)
124 {
125 --error 0, ER_LOCK_WAIT_TIMEOUT, ER_GET_TEMPORARY_ERRMSG
126 UPDATE dt_1 SET member_id = 6 WHERE member_id = 5;
127 if (!$mysql_errno)
128 {
129 # Query suceeded, no more retries
130 let $updated_ok = 1;
131 }
132
133 if ($mysql_errno)
134 {
135 # Query failed, check if another retry is allowed
136 dec $retries;
137 if (!$retries)
138 {
139 --die Updating many tuples in one trans fails after 10 retries.
140 }
141 --sleep 1
142 }
143 }
144 --enable_query_log
145
146 SELECT COUNT(*) AS "Records in dt_1 after update" FROM dt_1;
147
148 # Check that all records with member_id 5 was updated (ie. there should be none)
149 if (`SELECT COUNT(*) FROM dt_1 WHERE member_id = 5`)
150 {
151 die failed to update all records with member_id = 5 in dt_1;
152 }
153
154
155 --echo #
156 --echo # Test UNDO_TUP_DROP by dropping table dt_2
157 --echo #
158 DROP TABLE dt_2;
159
160 --echo # Show number of rows in dt_1 before restart for easy comparison
161 SELECT COUNT(*) AS "Number of rows before node restart" FROM dt_1;
162
163 --echo # Start LCP so that disk table pages are flushed to disk.
164 --echo # Otherwise, the undo log records are not sent to the LDM threads
165 --echo # for application
166 --exec $NDB_MGM -e "all dump 7099" >> $NDB_TOOLS_OUTPUT
167
168
169 --echo # Sleep until LCP (hopefully) has completed
170 sleep 10;
171
172
173 --echo # Restarting node 1 with nostart...
174 --exec $NDB_MGM -e "1 RESTART -n" >> $NDB_TOOLS_OUTPUT
175
176 --echo # Wait for node to reach not-started state...
177 --exec $NDB_WAITER --not-started --wait-nodes=1
178
179 --echo # Insert error to invalidate the latest LCP, so that the undo
180 --echo # records till the LCP start of the previous LCP are applied
181 --exec $NDB_MGM -e "1 ERROR 7248" >> $NDB_TOOLS_OUTPUT
182
183 --echo # Start node 1..
184 --exec $NDB_MGM -e "1 START" >> $NDB_TOOLS_OUTPUT
185
186 --echo # Wait for node 1 to start...
187 --exec $NDB_WAITER
188 --echo # Node 1 started
189
190 --echo # Clear error inserts
191 --exec $NDB_MGM -e "ALL ERROR 0" >> $NDB_TOOLS_OUTPUT
192
193 #
194 # Wait until the connection to the
195 # cluster has been restored or timeout occurs
196 #
197 --source include/ndb_not_readonly.inc
198
199 --echo # Check that existent data is still there
200 SELECT COUNT(*) AS "Number of rows after node restart" FROM dt_1;
201
202 --echo # Check that table can still be used to insert data
203 INSERT INTO dt_1 VALUES (2),(3),(4),(5);
204 SELECT COUNT(*) as "Number of rows after four more rows inserted" FROM dt_1;
205
206 --echo #
207 --echo # Check that data can be removed from the table (can cause temporary
208 --echo # timeout errors?) by removing all rows with member_id 1
209 --echo #
210 let $deleted_ok = 0;
211 let $retries = 10;
212 # Retry delete until it succeeds or retried too many times
213 --disable_query_log
214 while(!$deleted_ok)
215 {
216 --error 0, ER_LOCK_WAIT_TIMEOUT, ER_GET_TEMPORARY_ERRMSG
217 DELETE FROM dt_1 WHERE member_id = 1;
218 if (!$mysql_errno)
219 {
220 # Query suceeded, no more retries
221 let $deleted_ok = 1;
222 }
223
224 if ($mysql_errno)
225 {
226 # Query failed, check if another retry is allowed
227 dec $retries;
228 if (!$retries)
229 {
230 --die Deleting many tuples in one trans fails after 10 retries.
231 }
232 --sleep 1
233 }
234 }
235 --enable_query_log
236
237 SELECT COUNT(*) AS "Records in dt_1 after second delete" FROM dt_1;
238
239 # Check that all records with member_id 1 was deleted (ie. there should be none)
240 if (`SELECT COUNT(*) FROM dt_1 WHERE member_id = 1`)
241 {
242 die failed to delete all records with member_id = 1 from dt_1;
243 }
244
245 --echo # Check that table dt_2 still does not exist, it was removed
246 --echo # before node restart
247 --error ER_NO_SUCH_TABLE
248 SELECT * FROM dt_2;
249
250 --echo # Cleanup
251 DROP TABLE dt_1;
252
253 ALTER TABLESPACE ts_1
254 DROP DATAFILE 'data_2.dat';
255
256 ALTER TABLESPACE ts_1
257 DROP DATAFILE 'data_1.dat';
258
259 DROP TABLESPACE ts_1;
260
261 DROP LOGFILE GROUP lg_1
262 ENGINE NDBCLUSTER;
263
264 --remove_file $NDB_TOOLS_OUTPUT