Wait for tasks finish when scheduler failed

This commit is contained in:
Dmitry Novik 2023-02-15 15:50:06 +00:00
parent 3e77463125
commit cfb832b205

View File

@ -66,17 +66,7 @@ namespace
{ {
} }
virtual ~UploadHelper() virtual ~UploadHelper() = default;
{
try
{
waitForAllBackGroundTasks();
}
catch (...)
{
tryLogCurrentException(__PRETTY_FUNCTION__);
}
}
protected: protected:
std::shared_ptr<const S3::Client> client_ptr; std::shared_ptr<const S3::Client> client_ptr;
@ -219,6 +209,8 @@ namespace
size_t position = start_offset; size_t position = start_offset;
size_t end_position = start_offset + size; size_t end_position = start_offset + size;
try
{
for (size_t part_number = 1; position < end_position; ++part_number) for (size_t part_number = 1; position < end_position; ++part_number)
{ {
if (multipart_upload_aborted) if (multipart_upload_aborted)
@ -231,6 +223,14 @@ namespace
position = next_position; position = next_position;
} }
}
catch (...)
{
tryLogCurrentException(__PRETTY_FUNCTION__);
abortMultipartUpload();
waitForAllBackGroundTasks();
throw;
}
waitForAllBackGroundTasks(); waitForAllBackGroundTasks();
completeMultipartUpload(); completeMultipartUpload();