Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix possible race in ManyAggregatedData dtor. #58624

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Interpreters/Aggregator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2856,7 +2856,7 @@ void NO_INLINE Aggregator::mergeBucketImpl(
}
}

ManyAggregatedDataVariants Aggregator::prepareVariantsToMerge(ManyAggregatedDataVariants & data_variants) const
ManyAggregatedDataVariants Aggregator::prepareVariantsToMerge(ManyAggregatedDataVariants && data_variants) const
{
if (data_variants.empty())
throw Exception(ErrorCodes::EMPTY_DATA_PASSED, "Empty data passed to Aggregator::prepareVariantsToMerge.");
Expand Down
2 changes: 1 addition & 1 deletion src/Interpreters/Aggregator.h
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ class Aggregator final
*/
BlocksList convertToBlocks(AggregatedDataVariants & data_variants, bool final, size_t max_threads) const;

ManyAggregatedDataVariants prepareVariantsToMerge(ManyAggregatedDataVariants & data_variants) const;
ManyAggregatedDataVariants prepareVariantsToMerge(ManyAggregatedDataVariants && data_variants) const;

using BucketToBlocks = std::map<Int32, BlocksList>;
/// Merge partially aggregated blocks separated to buckets into one data structure.
Expand Down
4 changes: 2 additions & 2 deletions src/Processors/Transforms/AggregatingTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -732,14 +732,14 @@ void AggregatingTransform::initGenerate()
{
if (!skip_merging)
{
auto prepared_data = params->aggregator.prepareVariantsToMerge(many_data->variants);
auto prepared_data = params->aggregator.prepareVariantsToMerge(std::move(many_data->variants));
auto prepared_data_ptr = std::make_shared<ManyAggregatedDataVariants>(std::move(prepared_data));
processors.emplace_back(
std::make_shared<ConvertingAggregatedToChunksTransform>(params, std::move(prepared_data_ptr), max_threads));
}
else
{
auto prepared_data = params->aggregator.prepareVariantsToMerge(many_data->variants);
auto prepared_data = params->aggregator.prepareVariantsToMerge(std::move(many_data->variants));
Pipes pipes;
for (auto & variant : prepared_data)
{
Expand Down