matrixorigin / matrixone

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

[Bug]: prepare panic in tpcc partition table #16753

Open ouyuanning opened 1 month ago

ouyuanning commented 1 month ago

Is there an existing issue for the same bug?

Branch Name

main

Commit ID

9d9c849b2dca43f1cd0fb13d544000c58721e2d4

Other Environment Information

- Hardware parameters:
- OS type:
- Others:

Actual Behavior

prepare panic in tpcc partition table

Expected Behavior

No response

Steps to Reproduce

load tpcc data in partition tables.
run:

select mo_ctl('cn', 'task', 'disable');
use tpcc;
prepare s1 from SELECT c_discount, c_last, c_credit, w_tax FROM bmsql_customer JOIN bmsql_warehouse ON (w_id = c_w_id)  WHERE c_w_id = ? AND c_d_id = ? AND c_id = ?;
set @a=5;
set @b=9;
set @c=37;
execute s1 using @a,@b,@c;
execute s1 using @a,@b,@c;

set @a=372434432;
execute s1 using @a,@b,@c;  --- panic here

panic stack:

error: internal error: panic runtime error: slice bounds out of range [224:0]: 
runtime.goPanicSliceB
\t/usr/local/go/src/runtime/panic.go:154
github.com/matrixorigin/matrixone/pkg/objectio.(*BlockInfoSlice).Slice
\t/Users/ouyuanning/workspace/go/src/matrixone/pkg/objectio/block_info.go:124
github.com/matrixorigin/matrixone/pkg/sql/compile.buildScanParallelRun
\t/Users/ouyuanning/workspace/go/src/matrixone/pkg/sql/compile/scope.go:602
github.com/matrixorigin/matrixone/pkg/sql/compile.(*Scope).ParallelRun
\t/Users/ouyuanning/workspace/go/src/matrixone/pkg/sql/compile/scope.go:346
github.com/matrixorigin/matrixone/pkg/sql/compile.(*Scope).RemoteRun
\t/Users/ouyuanning/workspace/go/src/matrixone/pkg/sql/compile/scope.go:291
github.com/matrixorigin/matrixone/pkg/sql/compile.(*Scope).MergeRun.func1
\t/Users/ouyuanning/workspace/go/src/matrixone/pkg/sql/compile/scope.go:223
github.com/panjf2000/ants/v2.(*goWorker).run.func1
\t/Users/ouyuanning/workspace/go/src/matrixone/vendor/github.com/panjf2000/ants/v2/worker.go:67
runtime.goexit
\t/usr/local/go/src/runtime/asm_arm64.s:1222","span":{"trace_id":"05be89ab-7d3d-50b0-3902-62b5b50e895c","span_id":"6d530c11385d865f"}}
{"level":"ERROR","time":"2024/06/07 16:07:29.105354 +0800","name":"log-service.txn","caller":"compile/scope.go:321","msg":"panic in scope run","uuid":"7c4dccb4-4d3c-41f8-b482-5251dc7a41bf","sql":"execute s1 using @a,@b,@c","error":"internal error: panic runtime error: slice bounds out of range [224:0]: 
runtime.goPanicSliceB
\t/usr/local/go/src/runtime/panic.go:154
github.com/matrixorigin/matrixone/pkg/objectio.(*BlockInfoSlice).Slice
\t/Users/ouyuanning/workspace/go/src/matrixone/pkg/objectio/block_info.go:124
github.com/matrixorigin/matrixone/pkg/sql/compile.buildScanParallelRun
\t/Users/ouyuanning/workspace/go/src/matrixone/pkg/sql/compile/scope.go:602
github.com/matrixorigin/matrixone/pkg/sql/compile.(*Scope).ParallelRun
\t/Users/ouyuanning/workspace/go/src/matrixone/pkg/sql/compile/scope.go:346
github.com/matrixorigin/matrixone/pkg/sql/compile.(*Scope).RemoteRun
\t/Users/ouyuanning/workspace/go/src/matrixone/pkg/sql/compile/scope.go:291
github.com/matrixorigin/matrixone/pkg/sql/compile.(*Scope).MergeRun.func1
\t/Users/ouyuanning/workspace/go/src/matrixone/pkg/sql/compile/scope.go:223
github.com/panjf2000/ants/v2.(*goWorker).run.func1
\t/Users/ouyuanning/workspace/go/src/matrixone/vendor/github.com/panjf2000/ants/v2/worker.go:67
runtime.goexit
\t/usr/local/go/src/runtime/asm_arm64.s:1222"


### Additional information

_No response_
qingxinhome commented 3 weeks ago

经过分析对比,导致该问题的原因是分区表的stats统计信息错误造成,对比如下:

企业微信截图_1718191933629 企业微信截图_17181916569997

分区表(5分区): --updateTableStats, approxObjectNum:5 --InfoFromZoneMap,subTable: %!%p0%!%bmsql_customer, NDVs: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0], DataTypes: [ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY] --InfoFromZoneMap,subTable: %!%p1%!%bmsql_customer, NDVs: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0], DataTypes: [ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY] --InfoFromZoneMap,subTable: %!%p2%!%bmsql_customer, NDVs: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0], DataTypes: [ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY] --InfoFromZoneMap,subTable: %!%p3%!%bmsql_customer, NDVs: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0], DataTypes: [ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY] --InfoFromZoneMap,subTable: %!%p4%!%bmsql_customer, NDVs: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0], DataTypes: [ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY] --InfoFromZoneMap, NDVs: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0], DataTypes: [ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY ANY] --statsInfo: map[__mo_cpkey_col:0 c_balance:0 c_city:0 c_credit:0 c_credit_lim:0 c_d_id:0 c_data:0 c_delivery_cnt:0 c_discount:0 c_first:0 c_id:0 c_last:0 c_middle:0 c_payment_cnt:0 c_phone:0 c_since:0 c_state:0 c_street_1:0 c_street_2:0 c_w_id:0 c_ytd_payment:0 c_zip:0]

普通表(没有分区): --updateTableStats, approxObjectNum:2 --InfoFromZoneMap, NDVs: [10 10 3000 5001 2.000018484010229 1004.6316744020538 300000 1 1 1 1 1 300000 300000 296291 678.1149791549984 10499.240625634164 299590 7.000226431741142 1.0000046209918805 300000 300000], DataTypes: [INT INT INT DECIMAL64 CHAR VARCHAR VARCHAR DECIMAL64 DECIMAL64 DECIMAL64 INT INT VARCHAR VARCHAR VARCHAR CHAR CHAR CHAR TIMESTAMP CHAR VARCHAR VARCHAR] --statsInfo: map[__mo_cpkey_col:300000 c_balance:1 c_city:296291 c_credit:2.000018484010229 c_credit_lim:1 c_d_id:10 c_data:300000 c_delivery_cnt:1 c_discount:5001 c_first:300000 c_id:3000 c_last:1004.6316744020538 c_middle:1.0000046209918805 c_payment_cnt:1 c_phone:299590 c_since:7.000226431741142 c_state:678.1149791549984 c_street_1:300000 c_street_2:300000 c_w_id:10 c_ytd_payment:1 c_zip:10499.240625634164]

qingxinhome commented 3 weeks ago

和罗飞确认:分区表的stats统计方式错误,罗飞会进行修改 @ouyuanning @triump2020

triump2020 commented 3 weeks ago

Not working on this

triump2020 commented 2 weeks ago

Not working on this

triump2020 commented 2 weeks ago

Not working on this

triump2020 commented 1 week ago

Not working on this

triump2020 commented 6 days ago

Not working on this

triump2020 commented 11 hours ago

Not working on this