Found in stress test: https://gist.github.com/alesapin/5cd6b8901488a1f170d5ef389900a534
Report: https://s3.amazonaws.com/clickhouse-test-reports/31158/7fb9a42b119b6c3eba1784caaabde51c1ded3384/stress_tests__debug__actions_.html
chunk.setChunkInfo(std::move(res_info));
    auto block = params->aggregator.mergeBlocks(blocks_list, params->final);
    size_t num_rows = block.rows();
    chunk.setColumns(block.getColumns(), num_rows);
}
SortingAggregatedTransform::SortingAggregatedTransform(size_t num_inputs_, AggregatingTransformParamsPtr params_)
    : IProcessor(InputPorts(num_inputs_, params_->getHeader()), {params_->getHeader()})
    , num_inputs(num_inputs_)
    , params(std::move(params_))
    , last_bucket_number(num_inputs, -1)
    , is_input_finished(num_inputs, false)
{
}
bool SortingAggregatedTransform::tryPushChunk()
{
    auto & output = outputs.front();
    if (chunks.empty())
        return false;
    
    auto it = chunks.begin();
    auto cur_bucket = it->first;
    
    for (size_t input = 0; input < num_inputs; ++input)
        if (!is_input_finished[input] && last_bucket_number[input] < cur_bucket)
            return false;
    output.push(std::move(it->second));
    chunks.erase(it);
    return true;
}
void SortingAggregatedTransform::addChunk(Chunk chunk, size_t from_input)