多层CAST会造成BE崩溃

【详述】执行如下的SQL会造成BE崩溃
【背景】执行如下SQL
【业务影响】
【是否存算分离】否
【StarRocks版本】例如:2.5.14
【集群规模】例如:3fe+3be(混布)
【机器信息】CPU虚拟核/内存/网卡 56C/256G/万兆
【联系方式】duanfangwei2012@sina.com / 社区6群-段方伟
【附件】
be.out (11.7 KB)

执行带2层cast的如下SQL,会造成BE挂掉

SQL

select 
cast( cast(json_query("{\"code\": 0, \"message\": \"OK\", \"request_id\": \"202401300503B060\", \"data\": {\"list\": [{\"dimensions\": {\"age\": \"AGE_35_44\", \"stat_time_day\": \"2024-01-29 00:00:00\", \"abc_id\": \"1789044582303745\"}, \"metrics\": {\"conversion\": \"0\", \"pro_type\": \"Other\", \"cam_name\": \"Y_TT_HX\", \"agroup_name\": \"Cost\", \"a_name\": \"T-X_17053723439111_XY024\ KR \\u9884\", \"clicks\": \"0\", \"placement_type\": \"ATT\", \"impressions\": \"321\", \"agroup_id\": \"1789044573130754\", \"cam_id\": \"1789044006970386\", \"mobile_app_id\": \"com.bbb.aaa.ea\", \"spend\": \"1.94\"}}], \"page_info\": {\"total_number\": 185, \"total_page\": 1, \"page_size\": 185, \"page\": 1}}}"
,'$.data.list[*].metrics.spend') as array<string>) as array<double>)

如果只有一层cast,则能执行成功


be.WARNING

W0130 14:01:50.890686 15071 mem_hook.cpp:254] large memory alloc: 4843524280 bytes, stack:
    @          0x4adaa6b  malloc
    @          0x80961b5  operator new()
    @          0x3c644dc  std::vector<>::reserve()
    @          0x3ffebdc  starrocks::vectorized::ColumnBuilder<>::ColumnBuilder()
    @          0x4009fd3  starrocks::vectorized::cast_float_from_string_fn<>()
    @          0x400a58d  starrocks::vectorized::VectorizedCastExpr<>::evaluate_checked()
    @          0x401a811  starrocks::vectorized::VectorizedCastArrayExpr::evaluate_checked()
    @          0x392cd63  starrocks::ExprContext::evaluate()
    @          0x392d0af  starrocks::ExprContext::evaluate()
    @          0x3046d04  starrocks::pipeline::ProjectOperator::push_chunk()
    @          0x2da89ee  starrocks::pipeline::PipelineDriver::process()
    @          0x51d1f2a  starrocks::pipeline::GlobalDriverExecutor::_worker_thread()
    @          0x4bbb122  starrocks::ThreadPool::dispatch_thread()
    @          0x4bb5bba  starrocks::Thread::supervise_thread()
    @     0x7f5f9e33bea5  start_thread
    @     0x7f5f9d956b0d  __clone
    @              (nil)  (unknown)

有复现SQL吗

已经复现,我们查下。高版本是没问题的,我们确认下2.5.16 crash的原因

Fix: https://github.com/StarRocks/starrocks/pull/42440