matrixorigin / matrixone

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

[Bug]: insert into table select from table mo reported panic runtime error: makeslice: len out of range #19599

Open heni02 opened 18 hours ago

heni02 commented 18 hours ago

Is there an existing issue for the same bug?

Branch Name

main

Commit ID

27fcb95

Other Environment Information

- Hardware parameters:
- OS type:
- Others:

Actual Behavior

insert into test01(b) select b from test01, test01表行数:8亿+,2列

企业微信截图_a15ce3be-e70b-438f-b839-b2665cd7ba6f

ddl: create table test01(a int auto_increment primary key,b int);

panic error: "statement":"insert into test01(b) select b from test01","status":"fail","error":"internal error: panic runtime error: makeslice: len out of range: \nruntime.panicmakeslicelen\n\t/usr/local/go/src/runtime/slice.go:29\nruntime.makeslice\n\t/usr/local/go/src/runtime/slice.go:111\ngithub.com/matrixorigin/matrixone/pkg/container/pSpool.initSpoolBuffer\n\t/go/src/github.com/matrixorigin/matrixone/pkg/container/pSpool/buffer.go:41\ngithub.com/matrixorigin/matrixone/pkg/container/pSpool.initCachedBatch\n\t/go/src/github.com/matrixorigin/matrixone/pkg/container/pSpool/copy.go:53\ngithub.com/matrixorigin/matrixone/pkg/container/pSpool.InitMyPipelineSpool\n\t/go/src/github.com/matrixorigin/matrixone/pkg/container/pSpool/method.go:33\ngithub.com/matrixorigin/matrixone/pkg/sql/colexec/dispatch.(Dispatch).Prepare\n\t/go/src/github.com/matrixorigin/matrixone/pkg/sql/colexec/dispatch/dispatch.go:51\ngithub.com/matrixorigin/matrixone/pkg/vm.Prepare.func1\n\t/go/src/github.com/matrixorigin/matrixone/pkg/vm/vm.go:37\ngithub.com/matrixorigin/matrixone/pkg/vm.doHandleAllOp\n\t/go/src/github.com/matrixorigin/matrixone/pkg/vm/types.go:574\ngithub.com/matrixorigin/matrixone/pkg/vm.HandleAllOp\n\t/go/src/github.com/matrixorigin/matrixone/pkg/vm/types.go:578\ngithub.com/matrixorigin/matrixone/pkg/vm.Prepare\n\t/go/src/github.com/matrixorigin/matrixone/pkg/vm/vm.go:36\ngithub.com/matrixorigin/matrixone/pkg/vm/pipeline.(Pipeline).run\n\t/go/src/github.com/matrixorigin/matrixone/pkg/vm/pipeline/pipeline.go:71\ngithub.com/matrixorigin/matrixone/pkg/vm/pipeline.(Pipeline).MergeRun\n\t/go/src/github.com/matrixorigin/matrixone/pkg/vm/pipeline/pipeline.go:67\ngithub.com/matrixorigin/matrixone/pkg/sql/compile.(Scope).Run\n\t/go/src/github.com/matrixorigin/matrixone/pkg/sql/compile/scope.go:165\ngithub.com/matrixorigin/matrixone/pkg/sql/compile.(Scope).ParallelRun\n\t/go/src/github.com/matrixorigin/matrixone/pkg/sql/compile/scope.go:447\ngithub.com/matrixorigin/matrixone/pkg/sql/compile.(Scope).MergeRun\n\t/go/src/github.com/matrixorigin/matrixone/pkg/sql/compile/scope.go:322\ngithub.com/matrixorigin/matrixone/pkg/sql/compile.(Scope).MergeRun.func1\n\t/go/src/github.com/matrixorigin/matrixone/pkg/sql/compile/scope.go:281\ngithub.com/panjf2000/ants/v2.(goWorker).run.func1\n\t/go/pkg/mod/github.com/panjf2000/ants/v2@v2.7.4/worker.go:67\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1700" mo log: https://shanghai.idc.matrixorigin.cn:30001/explore?panes=%7B%22t-5%22:%7B%22datasource%22:%22loki%22,%22queries%22:%5B%7B%22refId%22:%22A%22,%22expr%22:%22%7Bnamespace%3D%5C%22mo-cdc-test%5C%22%7D%20%7C%3D%20%60panic%60%22,%22queryType%22:%22range%22,%22datasource%22:%7B%22type%22:%22loki%22,%22uid%22:%22loki%22%7D,%22editorMode%22:%22builder%22%7D%5D,%22range%22:%7B%22from%22:%221729840989212%22,%22to%22:%221729844589212%22%7D%7D%7D&schemaVersion=1&orgId=1

Expected Behavior

No response

Steps to Reproduce

mysql> create database test_db;
Query OK, 1 row affected (0.03 sec)

mysql> use test_db;
Database changed
mysql> create table test01(a int auto_increment primary key,b int);
Query OK, 0 rows affected (0.04 sec)

mysql> select count(*) from test01;
+----------+
| count(*) |
+----------+
|  3295352 |
+----------+
1 row in set (0.20 sec)

mysql> insert into test01(b) select b from test01;
Query OK, 3295352 rows affected (2.48 sec)

mysql> insert into test01(b) select b from test01;
Query OK, 6590704 rows affected (4.49 sec)

mysql> insert into test01(b) select b from test01;
Query OK, 13181408 rows affected (5.23 sec)

mysql> insert into test01(b) select b from test01;
ERROR 1062 (HY000): Duplicate entry '19998465' for key 'a'
mysql> insert into test01(b) select b from test01;
Query OK, 26362816 rows affected (6.15 sec)

mysql> insert into test01(b) select b from test01;
Query OK, 52725632 rows affected (12.66 sec)

mysql> insert into test01(b) select b from test01;
Query OK, 105451264 rows affected (13.76 sec)

mysql> insert into test01(b) select b from test01;
Query OK, 210902528 rows affected (29.25 sec)

mysql> insert into test01(b) select b from test01;
Query OK, 421805056 rows affected (52.54 sec)

mysql> insert into test01(b) select b from test01;
ERROR 2013 (HY000): Lost connection to MySQL server during query
No connection. Trying to reconnect...
Connection id:    21666
Current database: test_db

ERROR 20101 (HY000): internal error: panic runtime error: makeslice: len out of range:
runtime.panicmakeslicelen
    /usr/local/go/src/runtime/slice.go:29
runtime.makeslice
    /usr/local/go/src/runtime/slice.go:111
github.com/matrixorigin/matrixone/pkg/container/pSpool.initSpoolBuffer
    /go/src/github.com/matrixorigin/matrixone/pkg/container/pSpool/buffer.go:41
github.com/matrixorigin/matrixone/pkg/container/pSpool.initCachedBatch
    /go/src/github.com/matrixorigin/matrixone/pkg/container/pSpool/copy.go:53
github.com/matrixorigin/mat
mysql> insert into test01(b) select b from test01;
ERROR 20101 (HY000): internal error: panic runtime error: makeslice: len out of range:
runtime.panicmakeslicelen
    /usr/local/go/src/runtime/slice.go:29
runtime.makeslice
    /usr/local/go/src/runtime/slice.go:111
github.com/matrixorigin/matrixone/pkg/container/pSpool.initSpoolBuffer
    /go/src/github.com/matrixorigin/matrixone/pkg/container/pSpool/buffer.go:41
github.com/matrixorigin/matrixone/pkg/container/pSpool.initCachedBatch
    /go/src/github.com/matrixorigin/matrixone/pkg/container/pSpool/copy.go:53
github.com/matrixorigin/mat
mysql> select count(*) from test01;
+-----------+
| count(*)  |
+-----------+
| 843610112 |
+-----------+
1 row in set (0.02 sec)

Additional information

No response

m-schen commented 17 hours ago

部分情况下 localregs的长度超过了127 (int8的极限),太离谱了。产生越界因此变成了负数长度,在make slice的时候出错了。

不过为了避免之后在高性能机器上跑(核数很多),将int8类型改成了uint32