File: local_dml.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (297 lines) | stat: -rw-r--r-- 8,153 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# Test clone with concurrent DML

if (!$no_binlog) {
--source include/have_log_bin.inc
}
--source include/have_innodb_default_undo_tablespaces.inc
--source ../include/clone_connection_begin.inc

if ($disabled_redo) {
  ALTER INSTANCE DISABLE INNODB REDO_LOG;
}

--let $CLONE_DATADIR = $MYSQL_TMP_DIR/data_new
--let $CLONE_DATADIR1 = $MYSQL_TMP_DIR/data_new1

if ($clone_upgrade) {
  --eval INSTALL PLUGIN clone SONAME '$CLONE_PLUGIN'

  --echo # Upgrade 5.7 database
  --let $MYSQLD_DATADIR_UPGRADE = $MYSQL_TMP_DIR/data_upgrade
  --source ../include/clone_upgrade.inc

  --echo # Cloning database immediately after upgrade
  --replace_result $CLONE_PLUGIN CLONE_PLUGIN
  --eval INSTALL PLUGIN clone SONAME '$CLONE_PLUGIN'
  --connection clone_conn_1
  --source ../include/clone_command.inc

  select count(*) from 57_data_table;

  --echo # In connection default - Finished Cloning
  --connection default
  UNINSTALL PLUGIN clone;
}

--source include/count_sessions.inc

# Use a couple explicit undo tablespaces
CREATE UNDO TABLESPACE undo_003 ADD DATAFILE 'undo_003.ibu';
CREATE UNDO TABLESPACE undo_004 ADD DATAFILE 'undo_004.ibu';
SELECT NAME, SPACE_TYPE, STATE
       FROM INFORMATION_SCHEMA.INNODB_TABLESPACES
       WHERE SPACE_TYPE = 'Undo' ORDER BY NAME;
SELECT TABLESPACE_NAME, FILE_NAME, FILE_TYPE, ENGINE
       FROM INFORMATION_SCHEMA.FILES
       WHERE FILE_NAME LIKE '%undo_00%'
       ORDER BY TABLESPACE_NAME;

## Install plugin

--replace_result $CLONE_PLUGIN CLONE_PLUGIN
--eval INSTALL PLUGIN clone SONAME '$CLONE_PLUGIN'

SHOW VARIABLES LIKE "clone_buffer_size";

SET GLOBAL clone_buffer_size = 2097152;

SHOW VARIABLES LIKE "clone_buffer_size";

## Create test schema
--source ../include/create_schema.inc

# Replace tables with compressed row format tables
if ($row_format_compressed) {
DROP TABLE t1;
DROP TABLE t2;

CREATE TABLE t1(col1 INT PRIMARY KEY, col2 int, col3 varchar(64), col4 BLOB)
ROW_FORMAT = COMPRESSED;
CREATE TABLE t2(col1 INT PRIMARY KEY, col2 int, col3 varchar(64), col4 BLOB)
ROW_FORMAT = COMPRESSED;
}

## Execute Clone while concurrent DMLs are in progress
--let num_rows = 100

# Insert 1k rows to run clone for longer and test auto tuning
if ($clone_auto_tune) {
--let num_rows = 1000
--let clone_throttle = 1
}

if ($clone_ddl) {
  --let num_rows = 200
  --let clone_throttle = 1
}

# Insert rows
--eval call execute_dml(0, 0, $num_rows, $num_rows, 10, 0)

# Check base rows
SHOW CREATE TABLE t1;
SELECT count(*) from t1;
SELECT col1, col2, col3 FROM t1 ORDER BY col1 LIMIT 10;
SELECT col1, col2, col3 FROM t1 ORDER BY col1 DESC LIMIT 10;

SHOW CREATE TABLE t2;
SELECT count(*) from t2;
SELECT col1, col2, col3 FROM t2 ORDER BY col1 LIMIT 10;
SELECT col1, col2, col3 FROM t2 ORDER BY col1 DESC LIMIT 10;

--echo # In connection con1 - Running Insert Random [100 - 200 Key range]
connect (con1,localhost,root,,);
--send call execute_dml(0, 100, 100, 100, 20, 1)

--echo # In connection con2 - Running Update Random [0 - 25 Key Range]
connect (con2,localhost,root,,);
--send call execute_dml(1, 0, 25, 100, 20, 1)

--echo # In connection con3 - Running Delete Random [26 - 50 Key Range]
connect (con3,localhost,root,,);
--send call execute_dml(2, 26, 25, 100, 20, 1)

--echo # In connection con4 - Running Update Random uncommited [51 - 75 Key Range]
connect (con4,localhost,root,,);

if ($clone_ddl) {
  --send call execute_ddl(10)
}

if (!$clone_ddl) {
  begin;
  --send call execute_dml(1, 51, 25, 100, 200, 1)
}

--echo # In connection default - Cloning database
--connection clone_conn_1

if ($disabled_redo) {
  --echo # Clone must return error when redo logging is disabled
  --let disabled_redo = 0
  --let $clone_err = ER_INNODB_REDO_DISABLED
  --source ../include/clone_command.inc

  --let disabled_redo = 1
  --let $clone_err = 0
}

--source ../include/clone_command.inc
--echo # In connection default - Finished Cloning

show variables like 'clone_autotune_concurrency';

--echo # In connection con1 - Waiting
connection con1;
--reap

--echo # In connection con2 - Waiting
connection con2;
--reap

--echo # In connection con3 - Waiting
connection con3;
--reap

--echo # In connection con4 - Waiting
connection con4;
--reap
commit;

--echo # In connection default
connection default;

disconnect con1;
disconnect con2;
disconnect con3;
disconnect con4;

--source include/wait_until_count_sessions.inc

if (!$clone_remote_replace) {
  --echo # Restart cloned database
  --replace_result $CLONE_DATADIR CLONE_DATADIR
  --let restart_parameters="restart: --datadir=$CLONE_DATADIR"
  --source include/restart_mysqld.inc
}

if ($clone_remote_replace) {
  --connection clone_conn_1
}

select STATE, ERROR_NO, length(BINLOG_FILE) > 0, length(GTID_EXECUTED) > 0,
(BINLOG_POSITION > 0) from performance_schema.clone_status;

# Insert 2k rows with throttle to run clone for longer and test auto tuning
if ($clone_auto_tune) {
--let num_rows = 2000
--let clone_throttle = 0
}

# Execute procedure to delete all rows and insert
call execute_dml(3, 0, 1, 1, 1, 0);
--eval call execute_dml(0, 0, $num_rows, $num_rows, 10, 0)

# Check table in cloned database
SHOW CREATE TABLE t1;
SELECT count(*) from t1;
SELECT col1, col2, col3 FROM t1 ORDER BY col1 LIMIT 10;
SELECT col1, col2, col3 FROM t1 ORDER BY col1 DESC LIMIT 10;

SHOW CREATE TABLE t2;
SELECT count(*) from t2;
SELECT col1, col2, col3 FROM t2 ORDER BY col1 LIMIT 10;
SELECT col1, col2, col3 FROM t2 ORDER BY col1 DESC LIMIT 10;

SELECT NAME, SPACE_TYPE, STATE
       FROM INFORMATION_SCHEMA.INNODB_TABLESPACES
       WHERE SPACE_TYPE = 'Undo';
SELECT TABLESPACE_NAME, FILE_NAME, FILE_TYPE, ENGINE
       FROM INFORMATION_SCHEMA.FILES
       WHERE FILE_NAME LIKE '%undo_00%';

# Test clone after recovering from cloned databse
--let $CLONE_DATADIR = $CLONE_DATADIR1
--source ../include/clone_command.inc
--let $CLONE_DATADIR = $MYSQL_TMP_DIR/data_new

if (!$clone_remote_replace) {
  --echo # Restart cloned database
  --replace_result $CLONE_DATADIR1 CLONE_DATADIR1
  --let restart_parameters="restart: --datadir=$CLONE_DATADIR1"
  --source include/restart_mysqld.inc
}

select STATE, ERROR_NO, length(BINLOG_FILE) > 0, length(GTID_EXECUTED) > 0,
(BINLOG_POSITION > 0) from performance_schema.clone_status;

# Execute procedure to delete all rows and insert
call execute_dml(3, 0, 1, 1, 1, 0);
call execute_dml(0, 0, 100, 100, 10, 0);

# Check table in cloned database
SHOW CREATE TABLE t1;
SELECT count(*) from t1;
SELECT col1, col2, col3 FROM t1 ORDER BY col1 LIMIT 10;
SELECT col1, col2, col3 FROM t1 ORDER BY col1 DESC LIMIT 10;

SHOW CREATE TABLE t2;
SELECT count(*) from t2;
SELECT col1, col2, col3 FROM t2 ORDER BY col1 LIMIT 10;
SELECT col1, col2, col3 FROM t2 ORDER BY col1 DESC LIMIT 10;

#Cleanup
if (!$clone_remote_replace) {
--let restart_parameters="restart:"
--source include/restart_mysqld.inc
}
--connection default

# Drop the two explicit undo tablespaces
ALTER UNDO TABLESPACE undo_003 SET INACTIVE;
let $inactive_undo_space = undo_003;
source include/wait_until_undo_space_is_empty.inc;
DROP UNDO TABLESPACE undo_003;

ALTER UNDO TABLESPACE undo_004 SET INACTIVE;
let $inactive_undo_space = undo_004;
source include/wait_until_undo_space_is_empty.inc;
DROP UNDO TABLESPACE undo_004;

SELECT NAME, SPACE_TYPE, STATE
       FROM INFORMATION_SCHEMA.INNODB_TABLESPACES
       WHERE SPACE_TYPE = 'Undo' ORDER BY NAME;
SELECT TABLESPACE_NAME, FILE_NAME, FILE_TYPE, ENGINE
       FROM INFORMATION_SCHEMA.FILES
       WHERE FILE_NAME LIKE '%undo_00%'
       ORDER BY TABLESPACE_NAME;

--source ../include/drop_schema.inc

if (!$clone_remote_replace) {
--force-rmdir $CLONE_DATADIR
--force-rmdir $CLONE_DATADIR1
}

if ($clone_upgrade) {
  --echo # Cleanup: Restart with default options.
  --let $restart_parameters =
  --source include/restart_mysqld.inc

  --echo
  --echo # Remove upgraded data directory.
  --force-rmdir $MYSQLD_DATADIR_UPGRADE
}

# Clean recipient by cloning the cleaned up donor
if ($clone_remote_replace) {
  --connection clone_conn_1
  --source ../include/clone_command.inc
}
--source ../include/clone_connection_end.inc

UNINSTALL PLUGIN clone;

if ($disabled_redo) {
  ALTER INSTANCE ENABLE INNODB REDO_LOG;
}