Keep parent part alive for read task

This commit is contained in:
Antonio Andelic 2024-05-08 12:15:54 +02:00
parent 195ea4ec1f
commit 173d5d0b98
3 changed files with 21 additions and 1 deletions

View File

@ -53,7 +53,7 @@ MergeTreePrefetchedReadPool::PrefetchedReaders::PrefetchedReaders(
MergeTreePrefetchedReadPool & read_prefetch)
: is_valid(true)
, readers(std::move(readers_))
, prefetch_runner(pool, "Prefetch")
, prefetch_runner(pool, "ReadPrepare")
{
prefetch_runner(read_prefetch.createPrefetchedTask(readers.main.get(), priority_));

View File

@ -6,6 +6,11 @@
namespace DB
{
namespace ErrorCodes
{
extern const int LOGICAL_ERROR;
}
MergeTreeReadPoolBase::MergeTreeReadPoolBase(
RangesInDataParts && parts_,
VirtualFields shared_virtual_fields_,
@ -48,6 +53,19 @@ void MergeTreeReadPoolBase::fillPerPartInfos()
MergeTreeReadTaskInfo read_task_info;
read_task_info.data_part = part_with_ranges.data_part;
const auto & data_part = read_task_info.data_part;
if (data_part->isProjectionPart())
{
read_task_info.parent_part = data_part->storage.getPartIfExists(
data_part->getParentPartName(),
{MergeTreeDataPartState::PreActive, MergeTreeDataPartState::Active, MergeTreeDataPartState::Outdated});
if (!read_task_info.parent_part)
throw Exception(ErrorCodes::LOGICAL_ERROR, "Did not find parent part {} for projection part {}",
data_part->getParentPartName(), data_part->getDataPartStorage().getFullPath());
}
read_task_info.part_index_in_query = part_with_ranges.part_index_in_query;
read_task_info.alter_conversions = part_with_ranges.alter_conversions;

View File

@ -56,6 +56,8 @@ struct MergeTreeReadTaskInfo
{
/// Data part which should be read while performing this task
DataPartPtr data_part;
/// Parent part of the projection part
DataPartPtr parent_part;
/// For `part_index` virtual column
size_t part_index_in_query;
/// Alter converversionss that should be applied on-fly for part.