HashedDictionaryParallelLoader exception safe constructor

This commit is contained in:
Maksim Kita 2024-04-14 11:21:57 +03:00
parent b6cfba33f1
commit 7ebaa4d1ca

View File

@ -1,6 +1,7 @@
#pragma once
#include <Dictionaries/IDictionary.h>
#include <Dictionaries/DictionaryHelpers.h>
#include <Common/CurrentThread.h>
#include <Common/iota.h>
#include <Common/scope_guard_safe.h>
@ -62,6 +63,9 @@ public:
for (size_t shard = 0; shard < shards; ++shard)
{
shards_queues[shard].emplace(backlog);
try
{
pool.scheduleOrThrowOnError([this, shard, thread_group = CurrentThread::getGroup()]
{
WorkerStatistic statistic;
@ -85,6 +89,15 @@ public:
threadWorker(shard, statistic);
});
}
catch (...)
{
for (size_t shard_to_finish = 0; shard_to_finish < shard; ++shard_to_finish)
shards_queues[shard_to_finish]->clearAndFinish();
pool.wait();
throw;
}
}
}
void addBlock(Block block)