| 1353 | |
| 1354 | |
| 1355 | BackupStatus BackupsWorker::wait(const OperationID & backup_or_restore_id, bool rethrow_exception) |
| 1356 | { |
| 1357 | std::unique_lock lock{infos_mutex}; |
| 1358 | BackupStatus current_status = {}; |
| 1359 | status_changed.wait(lock, [&] |
| 1360 | { |
| 1361 | auto it = infos.find(backup_or_restore_id); |
| 1362 | if (it == infos.end()) |
| 1363 | throw Exception(ErrorCodes::LOGICAL_ERROR, "Unknown backup ID {}", backup_or_restore_id); |
| 1364 | const auto & info = it->second.info; |
| 1365 | current_status = info.status; |
| 1366 | if (rethrow_exception && isFailedOrCancelled(current_status)) |
| 1367 | std::rethrow_exception(info.exception); |
| 1368 | if (isFinalStatus(current_status)) |
| 1369 | return true; |
| 1370 | LOG_INFO(log, "Waiting {} {} to complete", isBackupStatus(current_status) ? "backup" : "restore", info.name); |
| 1371 | return false; |
| 1372 | }); |
| 1373 | return current_status; |
| 1374 | } |
| 1375 | |
| 1376 | void BackupsWorker::waitAll() |
| 1377 | { |
no test coverage detected