Debian Codegraph @

mysql-test/suite/clone/r/ddl_truncate.result

raw
1 INSTALL PLUGIN clone SONAME 'CLONE_PLUGIN';
2 CREATE TABLE t1(col1 INT PRIMARY KEY, col2 int, col3 varchar(64), col4 BLOB);
3 CREATE TABLE t2(col1 INT PRIMARY KEY, col2 int, col3 varchar(64), col4 BLOB)
4 PARTITION BY KEY(col1) PARTITIONS 5;
5 CREATE PROCEDURE execute_dml(
6 p_dml_type INT,
7 p_key_min INT,
8 p_key_range INT,
9 p_loop_count INT,
10 p_frequency INT,
11 p_is_rand INT)
12 BEGIN
13 DECLARE v_idx INT DEFAULT 0;
14 DECLARE v_commit INT DEFAULT 0;
15 DECLARE v_key INT DEFAULT 0;
16 /* Loop and INSERT data at random position */
17 WHILE(v_idx < p_loop_count) DO
18 /* Generate key between 1 to p_loop_count */
19 IF p_is_rand = 1 THEN
20 SET v_key = p_key_min + FLOOR(RAND() * p_key_range);
21 ELSE
22 SET v_key = p_key_min + (v_idx % p_key_range);
23 END IF;
24 CASE p_dml_type
25 WHEN 0 THEN
26 SET @clol3_text = CONCAT('Clone Test Row - ', v_key);
27 INSERT INTO t1 (col1, col2, col3, col4) VALUES (
28 v_key, v_key * 10,
29 @clol3_text, REPEAT('Large Column Data ', 2048))
30 ON DUPLICATE KEY UPDATE col2 = col2 + 1;
31 INSERT INTO t2 (col1, col2, col3, col4) VALUES (
32 v_key, v_key * 10,
33 @clol3_text, REPEAT('Large Column Data ', 2048))
34 ON DUPLICATE KEY UPDATE col2 = col2 + 1;
35 WHEN 1 THEN
36 UPDATE t1 SET col2 = v_idx + 1 WHERE col1 = v_key;
37 UPDATE t2 SET col2 = v_idx + 1 WHERE col1 = v_key;
38 WHEN 2 THEN
39 DELETE FROM t1 WHERE col1 = v_key;
40 DELETE FROM t2 WHERE col1 = v_key;
41 ELSE
42 DELETE FROM t1;
43 DELETE FROM t2;
44 END CASE;
45 SET v_idx = v_idx + 1;
46 /* Commit or rollback work at specified frequency. */
47 IF v_idx % p_frequency = 0 THEN
48 SET v_commit = FLOOR(RAND() * 2);
49 IF v_commit = 0 AND p_is_rand = 1 THEN
50 ROLLBACK;
51 START TRANSACTION;
52 ELSE
53 COMMIT;
54 START TRANSACTION;
55 END IF;
56 END IF;
57 END WHILE;
58 COMMIT;
59 END|
60 call execute_dml(0, 0, 100, 100, 10, 0);
61 CREATE TABLE t SELECT * FROM t1;
62 CREATE TABLE t0 (col1 INT PRIMARY KEY, col2 int, col3 varchar(64), col4 BLOB);
63 CREATE TABLE t01 (col1 INT PRIMARY KEY, col2 int, col3 varchar(64), col4 BLOB);
64 CREATE TABLE t3 (col1 INT PRIMARY KEY, col2 int, col3 varchar(64), col4 BLOB);
65 CREATE TABLE t11 (col1 INT PRIMARY KEY, col2 int, col3 varchar(64), col4 BLOB);
66 CREATE TABLE t21 (col1 INT PRIMARY KEY, col2 int, col3 varchar(64), col4 BLOB);
67 INSERT INTO t11 SELECT * FROM t;
68 INSERT INTO t21 SELECT * FROM t;
69 SHOW VARIABLES LIKE 'clone_ddl_timeout';
70 Variable_name Value
71 clone_ddl_timeout 300
72 SHOW VARIABLES LIKE 'clone_block_ddl';
73 Variable_name Value
74 clone_block_ddl OFF
75 # 1. TRUNCATE TABLE while clone in progress
76 SET global debug="+d,clone_send_deleted_block";
77 RESET MASTER;
78 SET GLOBAL DEBUG = '+d,local_release_clone_file_pin';
79 TRUNCATE TABLE t0 ;
80 SET DEBUG_SYNC = 'clone_before_init_meta SIGNAL start_ddl_file_init WAIT_FOR resume_file_init';
81 SET DEBUG_SYNC = 'clone_file_copy SIGNAL start_ddl_file WAIT_FOR resume_file';
82 SET DEBUG_SYNC = 'clone_file_copy_end_before_ack SIGNAL start_ddl_file_ack WAIT_FOR resume_file_ack';
83 SET DEBUG_SYNC = 'clone_before_file_ddl_meta SIGNAL start_ddl_file_meta WAIT_FOR resume_file_meta';
84 SET DEBUG_SYNC = 'clone_page_copy SIGNAL start_ddl_page WAIT_FOR resume_page';
85 SET DEBUG_SYNC = 'clone_before_page_ddl_meta SIGNAL start_ddl_page_meta WAIT_FOR resume_page_meta';
86 SET DEBUG_SYNC = 'clone_redo_copy SIGNAL start_ddl_redo WAIT_FOR resume_redo';
87 SET GLOBAL clone_autotune_concurrency = OFF;
88 SET GLOBAL clone_max_concurrency = 8;
89 CLONE LOCAL DATA DIRECTORY = 'CLONE_DATADIR';
90 # In connection CON1
91 # Waiting for clone to reach 'Initial metadata transfer'
92 SET DEBUG_SYNC = 'now WAIT_FOR start_ddl_file_init';
93 # Wait finished
94 TRUNCATE TABLE t01 ;
95 SET DEBUG_SYNC = 'now SIGNAL resume_file_init';
96 # Waiting for clone to reach 'file copy'
97 SET DEBUG_SYNC = 'now WAIT_FOR start_ddl_file';
98 # Wait finished
99 TRUNCATE TABLE t1 ;
100 CALL execute_dml(0, 0, 100, 100, 10, 0);
101 # Flush all dirty pages to track
102 SET GLOBAL innodb_buf_flush_list_now = 1;
103 SET DEBUG_SYNC = 'now SIGNAL resume_file';
104 SET DEBUG_SYNC = 'now WAIT_FOR start_ddl_file_ack';
105 SET DEBUG_SYNC = 'now SIGNAL resume_file_ack';
106 # Waiting for clone to reach DDL metadata for 'file copy'
107 SET DEBUG_SYNC = 'now WAIT_FOR start_ddl_file_meta';
108 # Wait finished
109 TRUNCATE TABLE t11 ;
110 INSERT INTO t11 SELECT * FROM t;
111 SET DEBUG_SYNC = 'now SIGNAL resume_file_meta';
112 # Waiting for clone to reach 'page copy'
113 SET DEBUG_SYNC = 'now WAIT_FOR start_ddl_page';
114 # Wait finished
115 TRUNCATE TABLE t2 ;
116 CALL execute_dml(0, 0, 100, 100, 10, 0);
117 SET DEBUG_SYNC = 'now SIGNAL resume_page';
118 # Waiting for clone to reach DDL metadata for 'page copy'
119 SET DEBUG_SYNC = 'now WAIT_FOR start_ddl_page_meta';
120 # Wait finished
121 TRUNCATE TABLE t21 ;
122 INSERT INTO t21 SELECT * FROM t;
123 SET DEBUG_SYNC = 'now SIGNAL resume_page_meta';
124 # Waiting for clone to reach 'redo copy'
125 SET DEBUG_SYNC = 'now WAIT_FOR start_ddl_redo';
126 # Wait finished
127 TRUNCATE TABLE t3 ;
128 SET DEBUG_SYNC = 'now SIGNAL resume_redo';
129 # In connection DEFAULT
130 # Waiting for clone to complete
131 # Wait finished
132 SET GLOBAL DEBUG = '-d,local_release_clone_file_pin';
133 # Restart server on cloned data directory
134 # restart: --datadir=CLONE_DATADIR
135 # Check cloned data
136 SHOW TABLES;
137 Tables_in_test
138 t
139 t0
140 t01
141 t1
142 t11
143 t2
144 t21
145 t3
146 SHOW CREATE TABLE t1;
147 Table Create Table
148 t1 CREATE TABLE `t1` (
149 `col1` int NOT NULL,
150 `col2` int DEFAULT NULL,
151 `col3` varchar(64) DEFAULT NULL,
152 `col4` blob,
153 PRIMARY KEY (`col1`)
154 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
155 CHECK TABLE t1 EXTENDED;
156 Table Op Msg_type Msg_text
157 test.t1 check status OK
158 SELECT count(*) from t1;
159 count(*)
160 100
161 SELECT col1, col2, col3 FROM t1 ORDER BY col1 LIMIT 10;;
162 col1 col2 col3
163 0 1 Clone Test Row - 0
164 1 11 Clone Test Row - 1
165 2 21 Clone Test Row - 2
166 3 31 Clone Test Row - 3
167 4 41 Clone Test Row - 4
168 5 51 Clone Test Row - 5
169 6 61 Clone Test Row - 6
170 7 71 Clone Test Row - 7
171 8 81 Clone Test Row - 8
172 9 91 Clone Test Row - 9
173 SELECT col1, col2, col3 FROM t1 ORDER BY col1 DESC LIMIT 10;;
174 col1 col2 col3
175 99 991 Clone Test Row - 99
176 98 981 Clone Test Row - 98
177 97 971 Clone Test Row - 97
178 96 961 Clone Test Row - 96
179 95 951 Clone Test Row - 95
180 94 941 Clone Test Row - 94
181 93 931 Clone Test Row - 93
182 92 921 Clone Test Row - 92
183 91 911 Clone Test Row - 91
184 90 901 Clone Test Row - 90
185 SHOW CREATE TABLE t11;
186 Table Create Table
187 t11 CREATE TABLE `t11` (
188 `col1` int NOT NULL,
189 `col2` int DEFAULT NULL,
190 `col3` varchar(64) DEFAULT NULL,
191 `col4` blob,
192 PRIMARY KEY (`col1`)
193 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
194 CHECK TABLE t11 EXTENDED;
195 Table Op Msg_type Msg_text
196 test.t11 check status OK
197 SELECT count(*) from t11;
198 count(*)
199 100
200 SELECT col1, col2, col3 FROM t11 ORDER BY col1 LIMIT 10;;
201 col1 col2 col3
202 0 0 Clone Test Row - 0
203 1 10 Clone Test Row - 1
204 2 20 Clone Test Row - 2
205 3 30 Clone Test Row - 3
206 4 40 Clone Test Row - 4
207 5 50 Clone Test Row - 5
208 6 60 Clone Test Row - 6
209 7 70 Clone Test Row - 7
210 8 80 Clone Test Row - 8
211 9 90 Clone Test Row - 9
212 SELECT col1, col2, col3 FROM t11 ORDER BY col1 DESC LIMIT 10;;
213 col1 col2 col3
214 99 990 Clone Test Row - 99
215 98 980 Clone Test Row - 98
216 97 970 Clone Test Row - 97
217 96 960 Clone Test Row - 96
218 95 950 Clone Test Row - 95
219 94 940 Clone Test Row - 94
220 93 930 Clone Test Row - 93
221 92 920 Clone Test Row - 92
222 91 910 Clone Test Row - 91
223 90 900 Clone Test Row - 90
224 SHOW CREATE TABLE t2;
225 Table Create Table
226 t2 CREATE TABLE `t2` (
227 `col1` int NOT NULL,
228 `col2` int DEFAULT NULL,
229 `col3` varchar(64) DEFAULT NULL,
230 `col4` blob,
231 PRIMARY KEY (`col1`)
232 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
233 /*!50100 PARTITION BY KEY (col1)
234 PARTITIONS 5 */
235 CHECK TABLE t2 EXTENDED;
236 Table Op Msg_type Msg_text
237 test.t2 check status OK
238 SELECT count(*) from t2;
239 count(*)
240 100
241 SELECT col1, col2, col3 FROM t2 ORDER BY col1 LIMIT 10;;
242 col1 col2 col3
243 0 0 Clone Test Row - 0
244 1 10 Clone Test Row - 1
245 2 20 Clone Test Row - 2
246 3 30 Clone Test Row - 3
247 4 40 Clone Test Row - 4
248 5 50 Clone Test Row - 5
249 6 60 Clone Test Row - 6
250 7 70 Clone Test Row - 7
251 8 80 Clone Test Row - 8
252 9 90 Clone Test Row - 9
253 SELECT col1, col2, col3 FROM t2 ORDER BY col1 DESC LIMIT 10;;
254 col1 col2 col3
255 99 990 Clone Test Row - 99
256 98 980 Clone Test Row - 98
257 97 970 Clone Test Row - 97
258 96 960 Clone Test Row - 96
259 95 950 Clone Test Row - 95
260 94 940 Clone Test Row - 94
261 93 930 Clone Test Row - 93
262 92 920 Clone Test Row - 92
263 91 910 Clone Test Row - 91
264 90 900 Clone Test Row - 90
265 call execute_dml(1, 0, 100, 100, 10, 0);
266 # Restart server back on base data directory
267 # restart:
268 SET DEBUG_SYNC = 'RESET';
269 # Cleanup
270 DROP TABLE t;
271 DROP TABLE t1;
272 DROP TABLE t2;
273 DROP PROCEDURE execute_dml;
274 DROP TABLE t0;
275 DROP TABLE t01;
276 DROP TABLE t3;
277 DROP TABLE t11;
278 DROP TABLE t21;
279 # Uninstall clone
280 UNINSTALL PLUGIN clone;