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
[&](size_t lhs_row, size_t rhs_row)
            {
                return less(res_key_columns, key_columns, lhs_row, rhs_row, group_by_description);
            });
        key_end = (it == indices.end() ? rows : *it);
        
        if (key_begin != key_end)
            params->aggregator.executeOnIntervalWithoutKeyImpl(variants.without_key, key_begin, key_end, aggregate_function_instructions.data(), variants.aggregates_pool);
        current_memory_usage = getCurrentMemoryUsage() - initial_memory_usage;
        
        if (key_end != rows)
        {
            params->aggregator.addSingleKeyToAggregateColumns(variants, res_aggregate_columns);
            
            if (cur_block_size >= max_block_size || cur_block_bytes + current_memory_usage >= max_block_bytes)
            {
                cur_block_bytes += current_memory_usage;
                finalizeCurrentChunk(std::move(chunk), key_end);
                return;
            }
            
            params->aggregator.createStatesAndFillKeyColumnsWithSingleKey(variants, key_columns, key_end, res_key_columns);
            ++cur_block_size;
        }
        key_begin = key_end;
    }
    cur_block_bytes += current_memory_usage;
    block_end_reached = false;
}
void AggregatingInOrderTransform::finalizeCurrentChunk(Chunk chunk, size_t key_end)