Skip to content

[Bug]: json_extract trigger connection Lost while query non-exist elem. #14909

Closed

Description

@xzxiong

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

main

Commit ID

3405fd8

Other Environment Information

- Hardware parameters: macbook pro M1
- OS type: macOS
- Others:

Actual Behavior

exist query select json_extract('[1,2,3]', '$[3]') got Error: ERROR 2013 (HY000): Lost connection to MySQL server during query

mysql> select json_extract('[1,2,3]', '$[3]');
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql> select json_extract('[1,2,3]', '$[3]');
ERROR 2013 (HY000): Lost connection to MySQL server during query
No connection. Trying to reconnect...
Connection id:    14226
Current database: system

ERROR 2013 (HY000): Lost connection to MySQL server during query

Expected Behavior

  1. return NULL if query the non-exists elem.
  2. the connection should keep going.
mysql>  select json_extract('[1,2,3]', '$[3]');
+---------------------------------+
| json_extract('[1,2,3]', '$[3]') |
+---------------------------------+
| NULL                            |
+---------------------------------+
1 row in set (0.01 sec)

Steps to Reproduce

1. build & startup mo
4. exec query `select json_extract('[1,2,3]', '$[3]');` twice

Additional information

No response

Activity

  1. added
    kind/bug
    on Mar 12, 2024
  2. added this to the 1.2.0 milestone on Mar 12, 2024
  3. added
    severity/s0
    on Mar 12, 2024
  4. YANGGMM commented on Mar 15, 2024

    @YANGGMM
    Contributor
    {"level":"ERROR","time":"2024/03/15 16:08:02.347812 +0800","caller":"vm/vm.go:121","msg":"error: internal error: panic runtime error: slice bounds out of range [:8201] with capacity 47: \nruntime.goPanicSliceAcap\n\t/opt/homebrew/Cellar/go/1.21.6/libexec/src/runtime/panic.go:140\ngithub.com/matrixorigin/matrixone/pkg/container/bytejson.ByteJson.getObjectKey\n\t/Users/yangzhao/matrixone/pkg/container/bytejson/bytejson.go:256\ngithub.com/matrixorigin/matrixone/pkg/container/bytejson.ByteJson.toObject\n\t/Users/yangzhao/matrixone/pkg/container/bytejson/bytejson.go:197\ngithub.com/matrixorigin/matrixone/pkg/container/bytejson.ByteJson.to\n\t/Users/yangzhao/matrixone/pkg/container/bytejson/bytejson.go:156\ngithub.com/matrixorigin/matrixone/pkg/container/bytejson.ByteJson.MarshalJSON\n\t/Users/yangzhao/matrixone/pkg/container/bytejson/bytejson.go:77\ngithub.com/matrixorigin/matrixone/pkg/container/bytejson.ByteJson.String\n\t/Users/yangzhao/matrixone/pkg/container/bytejson/bytejson.go:31\ngithub.com/matrixorigin/matrixone/pkg/frontend.(*MysqlResultSet).GetString\n\t/Users/yangzhao/matrixone/pkg/frontend/resultset.go:514\ngithub.com/matrixorigin/matrixone/pkg/frontend.(*MysqlProtocolImpl).makeResultSetTextRow\n\t/Users/yangzhao/matrixone/pkg/frontend/mysql_protocol.go:2178\ngithub.com/matrixorigin/matrixone/pkg/frontend.(*MysqlProtocolImpl).SendResultSetTextBatchRowSpeedup\n\t/Users/yangzhao/matrixone/pkg/frontend/mysql_protocol.go:2350\ngithub.com/matrixorigin/matrixone/pkg/frontend.(*outputQueue).flush\n\t/Users/yangzhao/matrixone/pkg/frontend/output.go:123\ngithub.com/matrixorigin/matrixone/pkg/frontend.getDataFromPipeline\n\t/Users/yangzhao/matrixone/pkg/frontend/mysql_cmd_executor.go:565\ngithub.com/matrixorigin/matrixone/pkg/sql/colexec/output.(*Argument).Call\n\t/Users/yangzhao/matrixone/pkg/sql/colexec/output/output.go:60\ngithub.com/matrixorigin/matrixone/pkg/vm.Run\n\t/Users/yangzhao/matrixone/pkg/vm/vm.go:135\ngithub.com/matrixorigin/matrixone/pkg/vm/pipeline.(*Pipeline).MergeRun\n\t/Users/yangzhao/matrixone/pkg/vm/pipeline/pipeline.go:156\ngithub.com/matrixorigin/matrixone/pkg/sql/compile.(*Scope).MergeRun\n\t/Users/yangzhao/matrixone/pkg/sql/compile/scope.go:209\ngithub.com/matrixorigin/matrixone/pkg/sql/compile.(*Compile).run\n\t/Users/yangzhao/matrixone/pkg/sql/compile/compile.go:344\ngithub.com/matrixorigin/matrixone/pkg/sql/compile.(*Compile).runOnce.func1\n\t/Users/yangzhao/matrixone/pkg/sql/compile/compile.go:616\ngithub.com/panjf2000/ants/v2.(*goWorker).run.func1\n\t/Users/yangzhao/matrixone/vendor/github.com/panjf2000/ants/v2/worker.go:67\nruntime.goexit\n\t/opt/homebrew/Cellar/go/1.21.6/libexec/src/runtime/asm_arm64.s:1197","span":{"trace_id":"a923baff-c62d-f9b4-095a-3e693c9ce27f","span_id":"d96551d2dd373b4f"}}
    {"level":"ERROR","time":"2024/03/15 16:08:02.347996 +0800","caller":"vm/vm.go:122","msg":"panic in vm.Run: internal error: panic runtime error: slice bounds out of range [:8201] with capacity 47: \nruntime.goPanicSliceAcap\n\t/opt/homebrew/Cellar/go/1.21.6/libexec/src/runtime/panic.go:140\ngithub.com/matrixorigin/matrixone/pkg/container/bytejson.ByteJson.getObjectKey\n\t/Users/yangzhao/matrixone/pkg/container/bytejson/bytejson.go:256\ngithub.com/matrixorigin/matrixone/pkg/container/bytejson.ByteJson.toObject\n\t/Users/yangzhao/matrixone/pkg/container/bytejson/bytejson.go:197\ngithub.com/matrixorigin/matrixone/pkg/container/bytejson.ByteJson.to\n\t/Users/yangzhao/matrixone/pkg/container/bytejson/bytejson.go:156\ngithub.com/matrixorigin/matrixone/pkg/container/bytejson.ByteJson.MarshalJSON\n\t/Users/yangzhao/matrixone/pkg/container/bytejson/bytejson.go:77\ngithub.com/matrixorigin/matrixone/pkg/container/bytejson.ByteJson.String\n\t/Users/yangzhao/matrixone/pkg/container/bytejson/bytejson.go:31\ngithub.com/matrixorigin/matrixone/pkg/frontend.(*MysqlResultSet).GetString\n\t/Users/yangzhao/matrixone/pkg/frontend/resultset.go:514\ngithub.com/matrixorigin/matrixone/pkg/frontend.(*MysqlProtocolImpl).makeResultSetTextRow\n\t/Users/yangzhao/matrixone/pkg/frontend/mysql_protocol.go:2178\ngithub.com/matrixorigin/matrixone/pkg/frontend.(*MysqlProtocolImpl).SendResultSetTextBatchRowSpeedup\n\t/Users/yangzhao/matrixone/pkg/frontend/mysql_protocol.go:2350\ngithub.com/matrixorigin/matrixone/pkg/frontend.(*outputQueue).flush\n\t/Users/yangzhao/matrixone/pkg/frontend/output.go:123\ngithub.com/matrixorigin/matrixone/pkg/frontend.getDataFromPipeline\n\t/Users/yangzhao/matrixone/pkg/frontend/mysql_cmd_executor.go:565\ngithub.com/matrixorigin/matrixone/pkg/sql/colexec/output.(*Argument).Call\n\t/Users/yangzhao/matrixone/pkg/sql/colexec/output/output.go:60\ngithub.com/matrixorigin/matrixone/pkg/vm.Run\n\t/Users/yangzhao/matrixone/pkg/vm/vm.go:135\ngithub.com/matrixorigin/matrixone/pkg/vm/pipeline.(*Pipeline).MergeRun\n\t/Users/yangzhao/matrixone/pkg/vm/pipeline/pipeline.go:156\ngithub.com/matrixorigin/matrixone/pkg/sql/compile.(*Scope).MergeRun\n\t/Users/yangzhao/matrixone/pkg/sql/compile/scope.go:209\ngithub.com/matrixorigin/matrixone/pkg/sql/compile.(*Compile).run\n\t/Users/yangzhao/matrixone/pkg/sql/compile/compile.go:344\ngithub.com/matrixorigin/matrixone/pkg/sql/compile.(*Compile).runOnce.func1\n\t/Users/yangzhao/matrixone/pkg/sql/compile/compile.go:616\ngithub.com/panjf2000/ants/v2.(*goWorker).run.func1\n\t/Users/yangzhao/matrixone/vendor/github.com/panjf2000/ants/v2/worker.go:67\nruntime.goexit\n\t/opt/homebrew/Cellar/go/1.21.6/libexec/src/runtime/asm_arm64.s:1197"}
    {"level":"ERROR","time":"2024/03/15 16:08:02.348186 +0800","name":"log-service.frontend","caller":"frontend/mysql_cmd_executor.go:3224","msg":"internal error: panic runtime error: slice bounds out of range [:8201] with capacity 47: \nruntime.goPanicSliceAcap\n\t/opt/homebrew/Cellar/go/1.21.6/libexec/src/runtime/panic.go:140\ngithub.com/matrixorigin/matrixone/pkg/container/bytejson.ByteJson.getObjectKey\n\t/Users/yangzhao/matrixone/pkg/container/bytejson/bytejson.go:256\ngithub.com/matrixorigin/matrixone/pkg/container/bytejson.ByteJson.toObject\n\t/Users/yangzhao/matrixone/pkg/container/bytejson/bytejson.go:197\ngithub.com/matrixorigin/matrixone/pkg/container/bytejson.ByteJson.to\n\t/Users/yangzhao/matrixone/pkg/container/bytejson/bytejson.go:156\ngithub.com/matrixorigin/matrixone/pkg/container/bytejson.ByteJson.MarshalJSON\n\t/Users/yangzhao/matrixone/pkg/container/bytejson/bytejson.go:77\ngithub.com/matrixorigin/matrixone/pkg/container/bytejson.ByteJson.String\n\t/Users/yangzhao/matrixone/pkg/container/bytejson/bytejson.go:31\ngithub.com/matrixorigin/matrixone/pkg/frontend.(*MysqlResultSet).GetString\n\t/Users/yangzhao/matrixone/pkg/frontend/resultset.go:514\ngithub.com/matrixorigin/matrixone/pkg/frontend.(*MysqlProtocolImpl).makeResultSetTextRow\n\t/Users/yangzhao/matrixone/pkg/frontend/mysql_protocol.go:2178\ngithub.com/matrixorigin/matrixone/pkg/frontend.(*MysqlProtocolImpl).SendResultSetTextBatchRowSpeedup\n\t/Users/yangzhao/matrixone/pkg/frontend/mysql_protocol.go:2350\ngithub.com/matrixorigin/matrixone/pkg/frontend.(*outputQueue).flush\n\t/Users/yangzhao/matrixone/pkg/frontend/output.go:123\ngithub.com/matrixorigin/matrixone/pkg/frontend.getDataFromPipeline\n\t/Users/yangzhao/matrixone/pkg/frontend/mysql_cmd_executor.go:565\ngithub.com/matrixorigin/matrixone/pkg/sql/colexec/output.(*Argument).Call\n\t/Users/yangzhao/matrixone/pkg/sql/colexec/output/output.go:60\ngithub.com/matrixorigin/matrixone/pkg/vm.Run\n\t/Users/yangzhao/matrixone/pkg/vm/vm.go:135\ngithub.com/matrixorigin/matrixone/pkg/vm/pipeline.(*Pipeline).MergeRun\n\t/Users/yangzhao/matrixone/pkg/vm/pipeline/pipeline.go:156\ngithub.com/matrixorigin/matrixone/pkg/sql/compile.(*Scope).MergeRun\n\t/Users/yangzhao/matrixone/pkg/sql/compile/scope.go:209\ngithub.com/matrixorigin/matrixone/pkg/sql/compile.(*Compile).run\n\t/Users/yangzhao/matrixone/pkg/sql/compile/compile.go:344\ngithub.com/matrixorigin/matrixone/pkg/sql/compile.(*Compile).runOnce.func1\n\t/Users/yangzhao/matrixone/pkg/sql/compile/compile.go:616\ngithub.com/panjf2000/ants/v2.(*goWorker).run.func1\n\t/Users/yangzhao/matrixone/vendor/github.com/panjf2000/ants/v2/worker.go:67\nruntime.goexit\n\t/opt/homebrew/Cellar/go/1.21.6/libexec/src/runtime/asm_arm64.s:1197","uuid":"7c4dccb4-4d3c-41f8-b482-5251dc7a41bf","session_info":"connectionId 1515|127.0.0.1:53439|{account sys:dump:moadmin -- 0:1:0}|goRoutineId 2166|018e4127-5271-72df-bf47-36901d502c48","session_id":"018e4127-5271-72df-bf47-36901d502c48","statement_id":"018e4127-5c29-7f78-9d14-529546dd2354","txn_id":"018e41275c2a7f96a079ac1e2350d0b9/Active/S:1710490082343982000-1"}
    {"level":"ERROR","time":"2024/03/15 16:08:02.348375 +0800","name":"log-service.frontend","caller":"frontend/util.go:514","msg":"query trace status","uuid":"7c4dccb4-4d3c-41f8-b482-5251dc7a41bf","connection_id":1515,"statement":"select json_extract('[1,2,3]', '$[3]')","status":"fail","error":"internal error: panic runtime error: slice bounds out of range [:8201] with capacity 47: \nruntime.goPanicSliceAcap\n\t/opt/homebrew/Cellar/go/1.21.6/libexec/src/runtime/panic.go:140\ngithub.com/matrixorigin/matrixone/pkg/container/bytejson.ByteJson.getObjectKey\n\t/Users/yangzhao/matrixone/pkg/container/bytejson/bytejson.go:256\ngithub.com/matrixorigin/matrixone/pkg/container/bytejson.ByteJson.toObject\n\t/Users/yangzhao/matrixone/pkg/container/bytejson/bytejson.go:197\ngithub.com/matrixorigin/matrixone/pkg/container/bytejson.ByteJson.to\n\t/Users/yangzhao/matrixone/pkg/container/bytejson/bytejson.go:156\ngithub.com/matrixorigin/matrixone/pkg/container/bytejson.ByteJson.MarshalJSON\n\t/Users/yangzhao/matrixone/pkg/container/bytejson/bytejson.go:77\ngithub.com/matrixorigin/matrixone/pkg/container/bytejson.ByteJson.String\n\t/Users/yangzhao/matrixone/pkg/container/bytejson/bytejson.go:31\ngithub.com/matrixorigin/matrixone/pkg/frontend.(*MysqlResultSet).GetString\n\t/Users/yangzhao/matrixone/pkg/frontend/resultset.go:514\ngithub.com/matrixorigin/matrixone/pkg/frontend.(*MysqlProtocolImpl).makeResultSetTextRow\n\t/Users/yangzhao/matrixone/pkg/frontend/mysql_protocol.go:2178\ngithub.com/matrixorigin/matrixone/pkg/frontend.(*MysqlProtocolImpl).SendResultSetTextBatchRowSpeedup\n\t/Users/yangzhao/matrixone/pkg/frontend/mysql_protocol.go:2350\ngithub.com/matrixorigin/matrixone/pkg/frontend.(*outputQueue).flush\n\t/Users/yangzhao/matrixone/pkg/frontend/output.go:123\ngithub.com/matrixorigin/matrixone/pkg/frontend.getDataFromPipeline\n\t/Users/yangzhao/matrixone/pkg/frontend/mysql_cmd_executor.go:565\ngithub.com/matrixorigin/matrixone/pkg/sql/colexec/output.(*Argument).Call\n\t/Users/yangzhao/matrixone/pkg/sql/colexec/output/output.go:60\ngithub.com/matrixorigin/matrixone/pkg/vm.Run\n\t/Users/yangzhao/matrixone/pkg/vm/vm.go:135\ngithub.com/matrixorigin/matrixone/pkg/vm/pipeline.(*Pipeline).MergeRun\n\t/Users/yangzhao/matrixone/pkg/vm/pipeline/pipeline.go:156\ngithub.com/matrixorigin/matrixone/pkg/sql/compile.(*Scope).MergeRun\n\t/Users/yangzhao/matrixone/pkg/sql/compile/scope.go:209\ngithub.com/matrixorigin/matrixone/pkg/sql/compile.(*Compile).run\n\t/Users/yangzhao/matrixone/pkg/sql/compile/compile.go:344\ngithub.com/matrixorigin/matrixone/pkg/sql/compile.(*Compile).runOnce.func1\n\t/Users/yangzhao/matrixone/pkg/sql/compile/compile.go:616\ngithub.com/panjf2000/ants/v2.(*goWorker).run.func1\n\t/Users/yangzhao/matrixone/vendor/github.com/panjf2000/ants/v2/worker.go:67\nruntime.goexit\n\t/opt/homebrew/Cellar/go/1.21.6/libexec/src/runtime/asm_arm64.s:1197","span":{"trace_id":"a923baff-c62d-f9b4-095a-3e693c9ce27f","span_id":"d96551d2dd373b4f"},"session_info":"connectionId 1515|127.0.0.1:53439|{account sys:dump:moadmin -- 0:1:0}|goRoutineId 2166|018e4127-5271-72df-bf47-36901d502c48","session_id":"018e4127-5271-72df-bf47-36901d502c48","statement_id":"018e4127-5c29-7f78-9d14-529546dd2354"}
  5. YANGGMM commented on Mar 19, 2024

    @YANGGMM
    Contributor

    fixed,plz test

  6. 2 remaining items

  7. removed their assignment
    on Apr 1, 2024
  8. assigned and unassigned on Apr 2, 2024
  9. reopened this on Apr 2, 2024
  10. xzxiong commented on Apr 2, 2024

    @xzxiong
    ContributorAuthor

    @YANGGMM 解决了 select json_extract('[1,2,3]', '$[3]');, 但是没解决

    select json_extract('[1,2,3]', '$[4]');
    select json_extract('[1,2,3]', '$[5]');
    select json_extract('[1,2,3]', '$[6]');
    ...
    
  11. YANGGMM commented on Apr 8, 2024

    @YANGGMM
    Contributor

    fixed,plz test

  12. Ariznawlll commented on Apr 9, 2024

    @Ariznawlll
    Collaborator

    qa环境
    commit v1.1.3-4cfce1a18-2024-04-09
    image

    image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugresolved/v1.1.2resolved/v1.1.3severity/s0

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions