mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 00:22:29 +00:00
HashedDictionaryParallelLoader exception safe constructor
This commit is contained in:
parent
b6cfba33f1
commit
7ebaa4d1ca
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <Dictionaries/IDictionary.h>
|
#include <Dictionaries/IDictionary.h>
|
||||||
|
#include <Dictionaries/DictionaryHelpers.h>
|
||||||
#include <Common/CurrentThread.h>
|
#include <Common/CurrentThread.h>
|
||||||
#include <Common/iota.h>
|
#include <Common/iota.h>
|
||||||
#include <Common/scope_guard_safe.h>
|
#include <Common/scope_guard_safe.h>
|
||||||
@ -62,28 +63,40 @@ public:
|
|||||||
for (size_t shard = 0; shard < shards; ++shard)
|
for (size_t shard = 0; shard < shards; ++shard)
|
||||||
{
|
{
|
||||||
shards_queues[shard].emplace(backlog);
|
shards_queues[shard].emplace(backlog);
|
||||||
pool.scheduleOrThrowOnError([this, shard, thread_group = CurrentThread::getGroup()]
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
WorkerStatistic statistic;
|
pool.scheduleOrThrowOnError([this, shard, thread_group = CurrentThread::getGroup()]
|
||||||
SCOPE_EXIT_SAFE(
|
{
|
||||||
LOG_TRACE(dictionary.log, "Finished worker for dictionary {} shard {}, processed {} blocks, {} rows, total time {}ms",
|
WorkerStatistic statistic;
|
||||||
dictionary_name, shard, statistic.total_blocks, statistic.total_rows, statistic.total_elapsed_ms);
|
SCOPE_EXIT_SAFE(
|
||||||
|
LOG_TRACE(dictionary.log, "Finished worker for dictionary {} shard {}, processed {} blocks, {} rows, total time {}ms",
|
||||||
|
dictionary_name, shard, statistic.total_blocks, statistic.total_rows, statistic.total_elapsed_ms);
|
||||||
|
|
||||||
|
if (thread_group)
|
||||||
|
CurrentThread::detachFromGroupIfNotDetached();
|
||||||
|
);
|
||||||
|
|
||||||
|
/// Do not account memory that was occupied by the dictionaries for the query/user context.
|
||||||
|
MemoryTrackerBlockerInThread memory_blocker;
|
||||||
|
|
||||||
if (thread_group)
|
if (thread_group)
|
||||||
CurrentThread::detachFromGroupIfNotDetached();
|
CurrentThread::attachToGroupIfDetached(thread_group);
|
||||||
);
|
setThreadName("HashedDictLoad");
|
||||||
|
|
||||||
/// Do not account memory that was occupied by the dictionaries for the query/user context.
|
LOG_TRACE(dictionary.log, "Starting worker for dictionary {}, shard {}", dictionary_name, shard);
|
||||||
MemoryTrackerBlockerInThread memory_blocker;
|
|
||||||
|
|
||||||
if (thread_group)
|
threadWorker(shard, statistic);
|
||||||
CurrentThread::attachToGroupIfDetached(thread_group);
|
});
|
||||||
setThreadName("HashedDictLoad");
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
for (size_t shard_to_finish = 0; shard_to_finish < shard; ++shard_to_finish)
|
||||||
|
shards_queues[shard_to_finish]->clearAndFinish();
|
||||||
|
|
||||||
LOG_TRACE(dictionary.log, "Starting worker for dictionary {}, shard {}", dictionary_name, shard);
|
pool.wait();
|
||||||
|
throw;
|
||||||
threadWorker(shard, statistic);
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user