| 1 |
## Common file for controlled DDL execution with concurrent Clone |
| 2 |
## |
| 3 |
## 1. ddl_op : DDL operation - CREATE TABLE, DROP TABLE, ALTER TABLE ... |
| 4 |
## 2. ddl_stmt : DDL statement text following table name |
| 5 |
## 3. ddl_post : Any other follow up clause like partition |
| 6 |
## 4. ddl_table_extn : Second table name extension - new [t1_new, t2_new ...] |
| 7 |
## 5. dml_stmt1 : DML to be executed after DDL during stage-1 FILE COPY |
| 8 |
## 6. dml_stmt11 : DML to be executed after DDL before sending DDL metadata in FILE COPY |
| 9 |
## 7. dml_stmt2 : DML to be executed after DDL during stage-1 PAGE COPY |
| 10 |
## 8. dml_stmt21 : DML to be executed after DDL before sending DDL metadata in PAGE COPY |
| 11 |
## 9. ddl_skip_check : Skip checking data. Used tables are dropped |
| 12 |
##10. ddl_encryption : restart server with keyring plugin |
| 13 |
|
| 14 |
--source include/count_sessions.inc |
| 15 |
|
| 16 |
## Get rid of the binary logs from previous run. |
| 17 |
RESET MASTER; |
| 18 |
|
| 19 |
--let $CLONE_DATADIR = $MYSQL_TMP_DIR/data_new |
| 20 |
--let $MYSQLD_DATADIR= `select @@datadir;` |
| 21 |
|
| 22 |
if ($remote_clone) { |
| 23 |
SET GLOBAL DEBUG = '+d,remote_release_clone_file_pin'; |
| 24 |
} |
| 25 |
|
| 26 |
if (!$remote_clone) { |
| 27 |
SET GLOBAL DEBUG = '+d,local_release_clone_file_pin'; |
| 28 |
} |
| 29 |
|
| 30 |
if ($ddl_encryption) { |
| 31 |
SET GLOBAL DEBUG = '+d,log_redo_with_invalid_master_key'; |
| 32 |
} |
| 33 |
|
| 34 |
if ($ddl_redo_encrypt) { |
| 35 |
--let $skip_ddl = 1 |
| 36 |
} |
| 37 |
|
| 38 |
--let $ddl_exec = 1 |
| 39 |
--let $table_num = 0 |
| 40 |
|
| 41 |
if (!$skip_ddl) { |
| 42 |
--source ../include/clone_exec_ddl.inc |
| 43 |
} |
| 44 |
|
| 45 |
if ($post_dml) { |
| 46 |
--let $after_dml = _after_dml |
| 47 |
--source ../include/clone_exec_ddl.inc |
| 48 |
--let $after_dml = |
| 49 |
} |
| 50 |
|
| 51 |
SET DEBUG_SYNC = 'clone_before_init_meta SIGNAL start_ddl_file_init WAIT_FOR resume_file_init'; |
| 52 |
SET DEBUG_SYNC = 'clone_file_copy SIGNAL start_ddl_file WAIT_FOR resume_file'; |
| 53 |
SET DEBUG_SYNC = 'clone_file_copy_end_before_ack SIGNAL start_ddl_file_ack WAIT_FOR resume_file_ack'; |
| 54 |
SET DEBUG_SYNC = 'clone_before_file_ddl_meta SIGNAL start_ddl_file_meta WAIT_FOR resume_file_meta'; |
| 55 |
SET DEBUG_SYNC = 'clone_page_copy SIGNAL start_ddl_page WAIT_FOR resume_page'; |
| 56 |
SET DEBUG_SYNC = 'clone_before_page_ddl_meta SIGNAL start_ddl_page_meta WAIT_FOR resume_page_meta'; |
| 57 |
SET DEBUG_SYNC = 'clone_redo_copy SIGNAL start_ddl_redo WAIT_FOR resume_redo'; |
| 58 |
--source ../include/clone_command_send.inc |
| 59 |
|
| 60 |
if ($ddl_file_copy) { |
| 61 |
--let $skip_ddl = |
| 62 |
} |
| 63 |
|
| 64 |
connect (con1,localhost,root,,); |
| 65 |
|
| 66 |
--echo # In connection CON1 |
| 67 |
|
| 68 |
if (!$remote_clone) { |
| 69 |
--echo # Waiting for clone to reach 'Initial metadata transfer' |
| 70 |
SET DEBUG_SYNC = 'now WAIT_FOR start_ddl_file_init'; |
| 71 |
--echo # Wait finished |
| 72 |
} |
| 73 |
|
| 74 |
--let $table_num = 01 |
| 75 |
|
| 76 |
if (!$skip_ddl) { |
| 77 |
--source ../include/clone_exec_ddl.inc |
| 78 |
} |
| 79 |
|
| 80 |
if ($post_dml) { |
| 81 |
--let $after_dml = _after_dml |
| 82 |
--source ../include/clone_exec_ddl.inc |
| 83 |
--let $after_dml = |
| 84 |
} |
| 85 |
|
| 86 |
SET DEBUG_SYNC = 'now SIGNAL resume_file_init'; |
| 87 |
|
| 88 |
--echo # Waiting for clone to reach 'file copy' |
| 89 |
SET DEBUG_SYNC = 'now WAIT_FOR start_ddl_file'; |
| 90 |
--echo # Wait finished |
| 91 |
|
| 92 |
--let $table_num = 1 |
| 93 |
|
| 94 |
if($remote_clone) { |
| 95 |
--echo # For remote clone, let the donor progress concurrently |
| 96 |
--echo # otherwise file pins may not be released causing deadlock |
| 97 |
SET DEBUG_SYNC = 'clone_notify_ddl SIGNAL resume_file'; |
| 98 |
} |
| 99 |
|
| 100 |
if (!$skip_ddl) { |
| 101 |
--source ../include/clone_exec_ddl.inc |
| 102 |
} |
| 103 |
|
| 104 |
--eval $dml_stmt1 |
| 105 |
|
| 106 |
--echo # Flush all dirty pages to track |
| 107 |
SET GLOBAL innodb_buf_flush_list_now = 1; |
| 108 |
|
| 109 |
if ($post_dml) { |
| 110 |
--let $after_dml = _after_dml |
| 111 |
--source ../include/clone_exec_ddl.inc |
| 112 |
--let $after_dml = |
| 113 |
} |
| 114 |
|
| 115 |
SET DEBUG_SYNC = 'now SIGNAL resume_file'; |
| 116 |
|
| 117 |
# For remote clone, DDL is executed concurrently. This is to |
| 118 |
# make sure that clone doesn't enter into page copy state |
| 119 |
SET DEBUG_SYNC = 'now WAIT_FOR start_ddl_file_ack'; |
| 120 |
SET DEBUG_SYNC = 'now SIGNAL resume_file_ack'; |
| 121 |
|
| 122 |
if (!$remote_clone) { |
| 123 |
--echo # Waiting for clone to reach DDL metadata for 'file copy' |
| 124 |
SET DEBUG_SYNC = 'now WAIT_FOR start_ddl_file_meta'; |
| 125 |
--echo # Wait finished |
| 126 |
} |
| 127 |
|
| 128 |
if(!$in_place_ddl) { |
| 129 |
--let $table_num = 11 |
| 130 |
|
| 131 |
if (!$skip_ddl) { |
| 132 |
--source ../include/clone_exec_ddl.inc |
| 133 |
} |
| 134 |
|
| 135 |
--eval $dml_stmt11 |
| 136 |
|
| 137 |
if ($post_dml) { |
| 138 |
--let $after_dml = _after_dml |
| 139 |
--source ../include/clone_exec_ddl.inc |
| 140 |
--let $after_dml = |
| 141 |
} |
| 142 |
} |
| 143 |
|
| 144 |
SET DEBUG_SYNC = 'now SIGNAL resume_file_meta'; |
| 145 |
|
| 146 |
--echo # Waiting for clone to reach 'page copy' |
| 147 |
SET DEBUG_SYNC = 'now WAIT_FOR start_ddl_page'; |
| 148 |
--echo # Wait finished |
| 149 |
|
| 150 |
if ($ddl_page_copy) { |
| 151 |
--let $skip_ddl = |
| 152 |
} |
| 153 |
|
| 154 |
# In place DDL currently waits for page copy to complete. Allow |
| 155 |
# clone to proceed concurrently. |
| 156 |
|
| 157 |
if($in_place_ddl) { |
| 158 |
SET DEBUG_SYNC = 'clone_notify_ddl SIGNAL resume_page'; |
| 159 |
} |
| 160 |
|
| 161 |
--let $table_num = 2 |
| 162 |
|
| 163 |
if (!$skip_ddl) { |
| 164 |
--source ../include/clone_exec_ddl.inc |
| 165 |
} |
| 166 |
|
| 167 |
--eval $dml_stmt2 |
| 168 |
|
| 169 |
if ($post_dml) { |
| 170 |
--let $after_dml = _after_dml |
| 171 |
--source ../include/clone_exec_ddl.inc |
| 172 |
--let $after_dml = |
| 173 |
} |
| 174 |
|
| 175 |
SET DEBUG_SYNC = 'now SIGNAL resume_page'; |
| 176 |
|
| 177 |
if (!$remote_clone) { |
| 178 |
--echo # Waiting for clone to reach DDL metadata for 'page copy' |
| 179 |
SET DEBUG_SYNC = 'now WAIT_FOR start_ddl_page_meta'; |
| 180 |
--echo # Wait finished |
| 181 |
} |
| 182 |
|
| 183 |
if ($remote_clone) { |
| 184 |
--echo # Waiting for clone to reach 'redo copy' |
| 185 |
SET DEBUG_SYNC = 'now WAIT_FOR start_ddl_redo'; |
| 186 |
--echo # Wait finished |
| 187 |
} |
| 188 |
|
| 189 |
--let $table_num = 21 |
| 190 |
|
| 191 |
if (!$skip_ddl) { |
| 192 |
--source ../include/clone_exec_ddl.inc |
| 193 |
} |
| 194 |
|
| 195 |
--eval $dml_stmt21 |
| 196 |
|
| 197 |
if ($post_dml) { |
| 198 |
--let $after_dml = _after_dml |
| 199 |
--source ../include/clone_exec_ddl.inc |
| 200 |
--let $after_dml = |
| 201 |
} |
| 202 |
|
| 203 |
if (!$remote_clone) { |
| 204 |
SET DEBUG_SYNC = 'now SIGNAL resume_page_meta'; |
| 205 |
|
| 206 |
--echo # Waiting for clone to reach 'redo copy' |
| 207 |
SET DEBUG_SYNC = 'now WAIT_FOR start_ddl_redo'; |
| 208 |
--echo # Wait finished |
| 209 |
} |
| 210 |
|
| 211 |
--let $table_num = 3 |
| 212 |
|
| 213 |
if (!$skip_ddl) { |
| 214 |
--source ../include/clone_exec_ddl.inc |
| 215 |
} |
| 216 |
|
| 217 |
if ($post_dml) { |
| 218 |
--let $after_dml = _after_dml |
| 219 |
--source ../include/clone_exec_ddl.inc |
| 220 |
--let $after_dml = |
| 221 |
} |
| 222 |
|
| 223 |
SET DEBUG_SYNC = 'now SIGNAL resume_redo'; |
| 224 |
|
| 225 |
connection default; |
| 226 |
--echo # In connection DEFAULT |
| 227 |
--echo # Waiting for clone to complete |
| 228 |
--reap |
| 229 |
--echo # Wait finished |
| 230 |
|
| 231 |
if ($remote_clone) { |
| 232 |
SET GLOBAL DEBUG = '-d,remote_release_clone_file_pin'; |
| 233 |
} |
| 234 |
|
| 235 |
if (!$remote_clone) { |
| 236 |
SET GLOBAL DEBUG = '-d,local_release_clone_file_pin'; |
| 237 |
} |
| 238 |
|
| 239 |
--disconnect con1 |
| 240 |
--source include/wait_until_count_sessions.inc |
| 241 |
|
| 242 |
--echo # Restart server on cloned data directory |
| 243 |
if ($ddl_encryption) { |
| 244 |
--replace_result $CLONE_DATADIR CLONE_DATADIR $KEYRING_PLUGIN KEYRING_PLUGIN $MYSQL_TMP_DIR MYSQL_TMP_DIR |
| 245 |
--let restart_parameters="restart: --datadir=$CLONE_DATADIR --early-plugin-load="keyring_file=$KEYRING_PLUGIN" --keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring" |
| 246 |
} |
| 247 |
|
| 248 |
if (!$ddl_encryption) { |
| 249 |
--replace_result $CLONE_DATADIR CLONE_DATADIR |
| 250 |
--let restart_parameters="restart: --datadir=$CLONE_DATADIR" |
| 251 |
} |
| 252 |
|
| 253 |
--source include/restart_mysqld.inc |
| 254 |
|
| 255 |
--let $ddl_exec = |
| 256 |
|
| 257 |
--echo # Check cloned data |
| 258 |
SHOW TABLES; |
| 259 |
|
| 260 |
if (!$ddl_skip_check) { |
| 261 |
--let $ddl_show = 1 |
| 262 |
|
| 263 |
--let $table_num = 1 |
| 264 |
--source ../include/clone_exec_ddl.inc |
| 265 |
|
| 266 |
--let $table_num = 11 |
| 267 |
--source ../include/clone_exec_ddl.inc |
| 268 |
|
| 269 |
--let $table_num = 2 |
| 270 |
--source ../include/clone_exec_ddl.inc |
| 271 |
|
| 272 |
--let $ddl_show = |
| 273 |
|
| 274 |
if ($dml_stmt_check) { |
| 275 |
--eval $dml_stmt_check |
| 276 |
} |
| 277 |
} |
| 278 |
|
| 279 |
--echo # Restart server back on base data directory |
| 280 |
|
| 281 |
if ($ddl_encryption) { |
| 282 |
--replace_result $KEYRING_PLUGIN KEYRING_PLUGIN $MYSQL_TMP_DIR MYSQL_TMP_DIR $ENCRYPT_DATADIR ENCRYPT_DATADIR |
| 283 |
--let restart_parameters=restart: --datadir=$ENCRYPT_DATADIR --early-plugin-load="keyring_file=$KEYRING_PLUGIN" --keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring |
| 284 |
} |
| 285 |
|
| 286 |
if (!$ddl_encryption) { |
| 287 |
|
| 288 |
if (!$skip_space_validation) { |
| 289 |
--let restart_parameters=restart: |
| 290 |
} |
| 291 |
|
| 292 |
if ($skip_space_validation) { |
| 293 |
--let restart_parameters=restart: --skip-innodb-validate-tablespace-paths |
| 294 |
} |
| 295 |
} |
| 296 |
|
| 297 |
--source include/restart_mysqld.inc |
| 298 |
|
| 299 |
if ($undo_encryption) { |
| 300 |
SET GLOBAL innodb_undo_log_encrypt = ON; |
| 301 |
SHOW VARIABLES LIKE 'innodb_undo_log_encrypt'; |
| 302 |
} |
| 303 |
|
| 304 |
--force-rmdir $CLONE_DATADIR |
| 305 |
SET DEBUG_SYNC = 'RESET'; |