Revert "Revert "Revert "Revert "make d-tor Finalizer more obvious""""

This commit is contained in:
Sema Checherinda 2024-12-06 18:04:01 +01:00 committed by GitHub
parent ec70b7839d
commit 689a154438
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 11 additions and 13 deletions

View File

@ -1,3 +1,4 @@
#include <exception>
#include <Storages/MergeTree/MergeTreeSink.h> #include <Storages/MergeTree/MergeTreeSink.h>
#include <Storages/StorageMergeTree.h> #include <Storages/StorageMergeTree.h>
#include <Interpreters/PartLog.h> #include <Interpreters/PartLog.h>
@ -44,6 +45,8 @@ MergeTreeSink::~MergeTreeSink()
if (!delayed_chunk) if (!delayed_chunk)
return; return;
chassert(isCancelled() || std::uncaught_exceptions());
for (auto & partition : delayed_chunk->partitions) for (auto & partition : delayed_chunk->partitions)
{ {
partition.temp_part.cancel(); partition.temp_part.cancel();

View File

@ -119,7 +119,7 @@ struct MergedBlockOutputStream::Finalizer::Impl
} }
void finish(); void finish();
void cancel(); void cancel() noexcept;
}; };
void MergedBlockOutputStream::Finalizer::finish() void MergedBlockOutputStream::Finalizer::finish()
@ -130,7 +130,7 @@ void MergedBlockOutputStream::Finalizer::finish()
to_finish->finish(); to_finish->finish();
} }
void MergedBlockOutputStream::Finalizer::cancel() void MergedBlockOutputStream::Finalizer::cancel() noexcept
{ {
std::unique_ptr<Impl> to_cancel = std::move(impl); std::unique_ptr<Impl> to_cancel = std::move(impl);
impl.reset(); impl.reset();
@ -167,7 +167,7 @@ void MergedBlockOutputStream::Finalizer::Impl::finish()
part->getDataPartStorage().removeFile(file_name); part->getDataPartStorage().removeFile(file_name);
} }
void MergedBlockOutputStream::Finalizer::Impl::cancel() void MergedBlockOutputStream::Finalizer::Impl::cancel() noexcept
{ {
writer.cancel(); writer.cancel();
@ -183,15 +183,8 @@ MergedBlockOutputStream::Finalizer::Finalizer(std::unique_ptr<Impl> impl_) : imp
MergedBlockOutputStream::Finalizer::~Finalizer() MergedBlockOutputStream::Finalizer::~Finalizer()
{ {
try if (impl)
{ cancel();
if (impl)
finish();
}
catch (...)
{
tryLogCurrentException(__PRETTY_FUNCTION__);
}
} }

View File

@ -55,7 +55,7 @@ public:
~Finalizer(); ~Finalizer();
void finish(); void finish();
void cancel(); void cancel() noexcept;
}; };
/// Finalize writing part and fill inner structures /// Finalize writing part and fill inner structures

View File

@ -179,6 +179,8 @@ ReplicatedMergeTreeSinkImpl<async_insert>::~ReplicatedMergeTreeSinkImpl()
if (!delayed_chunk) if (!delayed_chunk)
return; return;
chassert(isCancelled() || std::uncaught_exceptions());
for (auto & partition : delayed_chunk->partitions) for (auto & partition : delayed_chunk->partitions)
{ {
partition.temp_part.cancel(); partition.temp_part.cancel();