Remove logs from index file. - To make crash safe, we copy the content of index file from index_file_start_offset recored in log_info to crash safe index file firstly and then move the crash safe index file to index file. @param linfo Store here the found log file name and position to the NEXT log file name in
| 4317 | LOG_INFO_IO Got IO error while reading/writing file |
| 4318 | */ |
| 4319 | int MYSQL_BIN_LOG::remove_logs_from_index(LOG_INFO* log_info, bool need_update_threads) |
| 4320 | { |
| 4321 | if (open_crash_safe_index_file()) |
| 4322 | { |
| 4323 | sql_print_error("MYSQL_BIN_LOG::remove_logs_from_index failed to " |
| 4324 | "open the crash safe index file."); |
| 4325 | goto err; |
| 4326 | } |
| 4327 | |
| 4328 | if (copy_file(&index_file, &crash_safe_index_file, |
| 4329 | log_info->index_file_start_offset)) |
| 4330 | { |
| 4331 | sql_print_error("MYSQL_BIN_LOG::remove_logs_from_index failed to " |
| 4332 | "copy index file to crash safe index file."); |
| 4333 | goto err; |
| 4334 | } |
| 4335 | |
| 4336 | if (close_crash_safe_index_file()) |
| 4337 | { |
| 4338 | sql_print_error("MYSQL_BIN_LOG::remove_logs_from_index failed to " |
| 4339 | "close the crash safe index file."); |
| 4340 | goto err; |
| 4341 | } |
| 4342 | DBUG_EXECUTE_IF("fault_injection_copy_part_file", DBUG_SUICIDE();); |
| 4343 | |
| 4344 | if (move_crash_safe_index_file_to_index_file(false/*need_lock_index=false*/)) |
| 4345 | { |
| 4346 | sql_print_error("MYSQL_BIN_LOG::remove_logs_from_index failed to " |
| 4347 | "move crash safe index file to index file."); |
| 4348 | goto err; |
| 4349 | } |
| 4350 | |
| 4351 | // now update offsets in index file for running threads |
| 4352 | if (need_update_threads) |
| 4353 | adjust_linfo_offsets(log_info->index_file_start_offset); |
| 4354 | return 0; |
| 4355 | |
| 4356 | err: |
| 4357 | return LOG_INFO_IO; |
| 4358 | } |
| 4359 | |
| 4360 | /** |
| 4361 | Remove all logs before the given log from disk and from the index file. |
nothing calls this directly
no test coverage detected