Merge pull request #63323 from ClickHouse/use-getparentpartname

Try fix segfault in `MergeTreeReadPoolBase::createTask`
This commit is contained in:
Antonio Andelic 2024-05-09 06:52:12 +00:00 committed by GitHub
commit d1c20d08c3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6,6 +6,11 @@
namespace DB
{
namespace ErrorCodes
{
extern const int LOGICAL_ERROR;
}
MergeTreeReadPoolBase::MergeTreeReadPoolBase(
RangesInDataParts && parts_,
VirtualFields shared_virtual_fields_,
@ -113,9 +118,25 @@ MergeTreeReadTaskPtr MergeTreeReadPoolBase::createTask(
? std::make_unique<MergeTreeBlockSizePredictor>(*read_info->shared_size_predictor)
: nullptr; /// make a copy
auto get_part_name = [](const auto & task_info) -> const String &
auto get_part_name = [](const auto & task_info) -> String
{
return task_info.data_part->isProjectionPart() ? task_info.data_part->getParentPart()->name : task_info.data_part->name;
const auto & data_part = task_info.data_part;
if (data_part->isProjectionPart())
{
auto parent_part_name = data_part->getParentPartName();
auto parent_part = data_part->storage.getPartIfExists(
parent_part_name, {MergeTreeDataPartState::PreActive, MergeTreeDataPartState::Active, MergeTreeDataPartState::Outdated});
if (!parent_part)
throw Exception(ErrorCodes::LOGICAL_ERROR, "Did not find parent part {} for projection part {}",
parent_part_name, data_part->getDataPartStorage().getFullPath());
return parent_part_name;
}
return data_part->name;
};
auto extras = getExtras();