| 1395 | } |
| 1396 | |
| 1397 | BackupStatus BackupsWorker::cancel(const BackupOperationID & backup_or_restore_id, bool wait_) |
| 1398 | { |
| 1399 | QueryStatusPtr process_list_element; |
| 1400 | BackupStatus current_status = {}; |
| 1401 | |
| 1402 | { |
| 1403 | std::unique_lock lock{infos_mutex}; |
| 1404 | auto it = infos.find(backup_or_restore_id); |
| 1405 | if (it == infos.end()) |
| 1406 | throw Exception(ErrorCodes::LOGICAL_ERROR, "Unknown backup ID {}", backup_or_restore_id); |
| 1407 | |
| 1408 | const auto & extended_info = it->second; |
| 1409 | const auto & info = extended_info.info; |
| 1410 | current_status = info.status; |
| 1411 | if (isFinalStatus(current_status) || !extended_info.process_list_element) |
| 1412 | return current_status; |
| 1413 | |
| 1414 | LOG_INFO(log, "Cancelling {} {}", isBackupStatus(current_status) ? "backup" : "restore", info.name); |
| 1415 | process_list_element = extended_info.process_list_element; |
| 1416 | } |
| 1417 | |
| 1418 | process_list.sendCancelToQuery(process_list_element); |
| 1419 | |
| 1420 | if (!wait_) |
| 1421 | return current_status; |
| 1422 | |
| 1423 | return wait(backup_or_restore_id, /* rethrow_exception= */ false); |
| 1424 | } |
| 1425 | |
| 1426 | |
| 1427 | void BackupsWorker::cancelAll(bool wait_) |
no test coverage detected