触发bug:get_json_string(parse_json(get_json_string(respmessage, ‘$.data’)), concat(’$.’, k))
- SELECT 正常,INSERT 崩溃:同样的 SQL,SELECT 不报错,INSERT OVERWRITE 直接挂 BE,正常情况下两者应该行为一致
- 堆栈指向底层实现:崩溃在 _full_json_query_impl 这个底层函数,不是用户代码问题
- 执行路径差异:INSERT OVERWRITE 走InsertOverwriteJobRunner 路径,这个路径强制触发了Flat JSON 优化,但Flat JSON 对动态路径的处理有缺陷
- 错误信息不一致:flat json doesn’t support variables json path 是一个应该被优雅处理的错误,但实际上直接导致 BE 崩溃,说明错误处理本身也有问题
关键信息:
- 版本:3.3.13
- 复现条件:string 类型字段 + lambda 中 parse_json() + 动态路径 + INSERT OVERWRITE
- 现象:SELECT 正常,INSERT 触发 flat json doesn’t support variables json path 并导致 BE 崩溃
- 堆栈:_full_json_query_impl → LambdaFunction → ArrayMapExpr
:_full_json_query_impl<(starrocks::LogicalType)17>(starrocks::FunctionContext*, std::vector<std::shared_ptrstarrocks::Column, std::allocator<std::shared_ptr<starrocks::Colu�
@ 0x5f33de5 starrocks::JsonFunctions::get_native_json_string(starrocks::FunctionContext*, std::vector<std::shared_ptrstarrocks::Column, std::allocator<std::shared_ptrstarrocks::Column > > const&)
@ 0x5ebeb0c starrocks::VectorizedFunctionCallExpr::evaluate_checked(starrocks::ExprContext*, starrocks::Chunk*)
@ 0x5d3a7ee starrocks::VectorizedCastExpr<(starrocks::LogicalType)17, (starrocks::LogicalType)54, false>::evaluate_checked(starrocks::ExprContext*, starrocks::Chunk*)
@ 0x537c20b starrocks::ExprContext::evaluate(starrocks::Expr*, starrocks::Chunk*, unsigned char*)
@ 0x5ebe344 starrocks::VectorizedFunctionCallExpr::evaluate_checked(starrocks::ExprContext*, starrocks::Chunk*)
@ 0x5f28b4e starrocks::VectorizedIsNotNullPredicate::evaluate_checked(starrocks::ExprContext*, starrocks::Chunk*)
@ 0x5f9150a starrocks::LambdaFunction::evaluate_checked(starrocks::ExprContext*, starrocks::Chunk*)
@ 0x537c20b starrocks::ExprContext::evaluate(starrocks::Expr*, starrocks::Chunk*, unsigned char*)
@ 0x5f9c081 starrocks::StatusOr<std::shared_ptrstarrocks::Column > starrocks::ArrayMapExpr::evaluate_lambda_expr<false, false>(starrocks::ExprContext*, starrocks::Chunk*, std::vector<std::shared_ptrstarrocks::Column, std::allocator<std::shared_ptr<starrocks::Colum�
会导致 BE 崩溃的写法
核心触发条件:在 lambda 中对 parse_json() 返回的 JSON 类型执行动态路径查询,且在 INSERT OVERWRITE 或物化视图刷新时执行。
–
危险写法1:array_map 中 parse_json + 动态路径
array_map(
k -> get_json_string(parse_json(str_col), concat(’$.’, k)),
some_array
)
–
危险写法2:array_filter 中 parse_json + 动态路径
array_filter(
k -> json_keys(get_json_string(parse_json(str_col), concat(’$.’, k))) IS NOT NULL,
some_array
)
–
危险写法3:嵌套 parse_json + 动态路径
get_json_string(
parse_json(get_json_string(str_col, ‘$.data’)),
concat(’$.’, k)
)
–
危险写法4:物化视图中使用 map_from_arrays + 动态路径
– 不会崩溃但会报错,且可能引发大量刷新任务导致线程耗尽