Correctly stop copy tasks when exception thrown

This commit is contained in:
Antonio Andelic 2024-05-08 14:58:21 +02:00
parent 090ef99339
commit 16eb12a321

View File

@ -151,17 +151,19 @@ void IDisk::copyThroughBuffers(
{ {
ResultsCollector results; ResultsCollector results;
SCOPE_EXIT_SAFE(
for (auto & result : results)
result.wait();
for (auto & result : results)
result.get(); /// May rethrow an exception
);
/// Disable parallel write. We already copy in parallel. /// Disable parallel write. We already copy in parallel.
/// Avoid high memory usage. See test_s3_zero_copy_ttl/test.py::test_move_and_s3_memory_usage /// Avoid high memory usage. See test_s3_zero_copy_ttl/test.py::test_move_and_s3_memory_usage
write_settings.s3_allow_parallel_part_upload = false; write_settings.s3_allow_parallel_part_upload = false;
write_settings.azure_allow_parallel_part_upload = false; write_settings.azure_allow_parallel_part_upload = false;
asyncCopy(*this, from_path, *to_disk, to_path, copying_thread_pool, results, copy_root_dir, read_settings, write_settings, cancellation_hook); asyncCopy(*this, from_path, *to_disk, to_path, copying_thread_pool, results, copy_root_dir, read_settings, write_settings, cancellation_hook);
for (auto & result : results)
result.wait();
for (auto & result : results)
result.get(); /// May rethrow an exception
} }