matrixorigin / matrixone

Hyperconverged cloud-edge native database
https://docs.matrixorigin.cn/en
Apache License 2.0
1.79k stars 276 forks source link

[Bug]: table value function crash #8769

Closed fengttt closed 1 year ago

fengttt commented 1 year ago

Is there an existing issue for the same bug?

Environment

- Version or commit-id (e.g. v0.1.0 or 8b23a93):
- Hardware parameters:
- OS type:
- Others:

Actual Behavior

mysql> select e. from rawlog, unnest(rawlog.extra, '$.') e where caller like 'mometric%' limit 1; ERROR 20101 (HY000): internal error: panic runtime error: index out of range [10] with length 1: runtime.goPanicIndex /usr/local/go/src/runtime/panic.go:113 github.com/matrixorigin/matrixone/pkg/sql/colexec.EvalExpr /home/ftian/m/matrixone/pkg/sql/colexec/expr_eval.go:237 github.com/matrixorigin/matrixone/pkg/sql/colexec/table_function.unnestCall /home/ftian/m/matrixone/pkg/sql/colexec/table_function/unnest.go:117 github.com/matrixorigin/matrixone/pkg/sql/colexec/table_function.Call /home/ftian/m/matrixone/pkg/sql/colexec mysql>

Expected Behavior

Run this against system database

Steps to Reproduce

Run this against system database,

select e.* from rawlog, unnest(rawlog.extra, '$.*') e where caller like 'mometric%' limit 1;

Additional information

No response

zhangxu19830126 commented 1 year ago

@m-schen in expr_eval.go:237, vec := bat.Vecs[t.Col.ColPos],index out of slice. Should check index first

m-schen commented 1 year ago

no, we shouldn't do any length check here. may the plan give me a wrong index, or operator make a error to set a wrong index. I will do check tomorrow.

mooleetzi commented 1 year ago

maybe my fault, let me check

mooleetzi commented 1 year ago

crash seems to be solved by #8892 , but table function join type maybe need change to lateral. rewrite select e.* from rawlog, unnest(rawlog.extra, '$.*') e where caller like 'mometric%' limit 1; to with tt as (select * from rawlog where caller like 'mometric%' limit 1) select e.* from tt,unnest(tt.extra) e limit 1 works faster.

iceTTTT commented 1 year ago

Waiting merge of pr #8892

jianwan0214 commented 1 year ago

not report

jianwan0214 commented 1 year ago

work on it

jianwan0214 commented 1 year ago

fix with https://github.com/matrixorigin/matrixone/pull/9059

image
aressu1985 commented 1 year ago

fixed

mysql> select e. from rawlog, unnest(rawlog.extra, '$.') e where caller like 'mometric%' limit 1; Empty set (1 min 23.50 sec)

mysql>