tidb 5.0 执行sql 报错 ERROR 1105 (HY000): runtime error: index out of range [37] with length 37

TiDB 版本 v5.0.4
SQL 如下
SELECT t.id priceOperationId, t.main_type mainType, t.operate_type operateType, t.price_id priceId, t.hotel_id hotelId, t.roomtype_id roomTypeId, t.rateplan_id ratePlanId, t.begin_date beginDate, t.end_date endDate, t.rateplan_code ratePlanCode, t.gen_salecost genSaleCost, t.gen_saleprice genSalePrice, t.weekend_salecost weekendSaleCost, t.weekend_saleprice weekendSalePrice, t.allow_addbed allowAddBed, t.addbed_price addBedPrice, t.currency_code currencyCode, t.is_priceset isPriceSet, t.is_effective isEffective, t.audit_status auditStatus, t.rate_calculationmodeltype rateCalculationModelType, t.commission_calculationtype commissionCalculationType, t.weekdaycommission_calculationvalue weekdayCommissionCalculationValue, t.weekendcommission_calculationvalue weekendCommissionCalculationValue, t.weekday_netrate weekdayNetRate, t.weekend_netrate weekendNetRate, t.min_profit minProfit, t.max_profit maxProfit, t.create_time createTime, t.creator, t.creator_ip createIp, t.operate_time operateTime, t.operator, t.operate_ip operatorIp, t.price_type priceType
from price_operation_7 t join
(
SELECT auto_id from price_operation_7 b where b.hotel_id = ‘93291826’ and b.roomtype_id = ‘0225’ and b.rateplan_id = 159000751 and b.operate_time < ‘2022-01-19 14:57:43.316’ and b.begin_date <= ‘2022-01-19 00:00:00’ and b.end_date >= ‘2022-01-19 00:00:00’ order by operate_time desc limit 1
) as a on a.auto_id = t.auto_id and t.hotel_id = ‘93291826’ and t.roomtype_id = ‘0225’ and t.rateplan_id = 159000751 limit 1;

TiDB 执行SQL 报错
ERROR 1105 (HY000): runtime error: index out of range [37] with length 37
[err=“runtime error: index out of range [37] with length 37”] [stack="goroutine 31928340420 [running]:\ngithub.com/pingcap/tidb/server.(*clientConn).Run.func1(0x4048f40, 0xc23375c300, 0xc0f9b4ff00)\ \t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/server/conn.go:798 +0xee\ panic(0x37d3da0, 0xc09f6d3700)\ \t/usr/local/go/src/runtime/panic.go:679 +0x1b2\ngithub.com/pingcap/tidb/planner/core.(*joinReOrderSolver).optimizeRecursive(0x5fee320, 0x40a2c00, 0xc0fce16dc0, 0x409de20, 0xc0ef5e2fc0, 0x0, 0x0, 0x0, 0x0)\ \t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/core/rule_join_reorder.go:95 +0xa4d\ngithub.com/pingcap/tidb/planner/core.(*joinReOrderSolver).optimizeRecursive(0x5fee320, 0x40a2c00, 0xc0fce16dc0, 0x409df20, 0xc08b0b7960, 0x0, 0x0, 0x0, 0x0)\ \t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/core/rule_join_reorder.go:112 +0x894\ngithub.com/pingcap/tidb/planner/core.(*joinReOrderSolver).optimizeRecursive(0x5fee320, 0x40a2c00, 0xc0fce16dc0, 0x409e420, 0xc08b0b77a0, 0xc08b0b7800, 0xc0015d2c30, 0x36f8c20, 0xc0015d2c30)\ \t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/core/rule_join_reorder.go:112 +0x894\ngithub.com/pingcap/tidb/planner/core.(*joinReOrderSolver).optimize(0x5fee320, 0x4048f40, 0xc10074c540, 0x409e420, 0xc08b0b77a0, 0x409e420, 0xc08b0b77a0, 0x0, 0x0)\ \t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/core/rule_join_reorder.go:58 +0x5a\ngithub.com/pingcap/tidb/planner/core.logicalOptimize(0x4048f40, 0xc10074c540, 0x7142, 0x409df20, 0xc08b0b7880, 0x61e7bf3b, 0xc0deb6a3f8, 0x13e41a6, 0x61e7bf3b)\ \t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/core/optimizer.go:235 +0x116\ngithub.com/pingcap/tidb/planner/core.DoOptimize(0x4048f40, 0xc10074c540, 0x40a2c00, 0xc0fce16dc0, 0x7142, 0x409df20, 0xc08b0b7880, 0x0, 0x0, 0x0, …)\ \t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/core/optimizer.go:144 +0xb5\ngithub.com/pingcap/tidb/planner.optimize(0x4048f40, 0xc10074c540, 0x40a2c00, 0xc0fce16dc0, 0x4068080, 0xc08afb9300, 0x4094980, 0xc22936aa50, 0x0, 0x0, …)\ \t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/optimize.go:288 +0x66c\ngithub.com/pingcap/tidb/planner.Optimize(0x4048f40, 0xc10074c540, 0x40a2c00, 0xc0fce16dc0, 0x4068080, 0xc08afb9300, 0x4094980, 0xc22936aa50, 0x0, 0x0, …)\ \t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/optimize.go:124 +0x491\ngithub.com/pingcap/tidb/executor.(*Compiler).Compile(0xc0deb6ad60, 0x4048f40, 0xc10074c540, 0x406fee0, 0xc08afb9300, 0x0, 0x0, 0x0)\ \t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/executor/compiler.go:62 +0x294\ngithub.com/pingcap/tidb/session.(*session).ExecuteStmt(0xc0fce16dc0, 0x4048f40, 0xc10074c540, 0x406fee0, 0xc08afb9300, 0x0, 0x0, 0x0, 0x0)\ \t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/session/session.go:1433 +0x2c4\ngithub.com/pingcap/tidb/server.(*TiDBContext).ExecuteStmt(0xc23375cba0, 0x4048f40, 0xc10074c540, 0x406fee0, 0xc08afb9300, 0xc095a86bd0, 0x4048f40, 0xc10074c540, 0xc0deb6b130)\ \t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/server/driver_tidb.go:218 +0x68\ngithub.com/pingcap/tidb/server.(*clientConn).handleStmt(0xc0f9b4ff00, 0x4048f40, 0xc10074c540, 0x406fee0, 0xc08afb9300, 0x5feea40, 0x0, 0x0, 0x1, 0x0, …)\ \t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/server/conn.go:1694 +0x134\ngithub.com/pingcap/tidb/server.(*clientConn).handle

感觉是TiDB bug ,其他SQL执行正常 整个集群运行正常

1 个赞

image

1 个赞

报错 home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/core/rule_join_reorder.go:95
文件


执行函数

如果把sql里面的 order by operate_time desc limit 1 去掉 则不会报错。应该是tidb的 join bug

1 个赞

很有可能,这种index out of range的我也遇到过几个是bug的,有可能是两表的排序规则不一致,也有可能走了错误的执行计划触发了bug,这种可能需要坐下最小的复现步骤,然后让产研大佬排查了

1 个赞

我是同一张表 都是 price_operation_7

1 个赞

又这个问题… 这bug 不是fix 了么~ 狠 囧 啊

1 个赞

版本4的时候见过这个问题

1 个赞

3.x,4.x 都见过拉

1 个赞

新版本里解决了吧,注意看一下发版信息

1 个赞

那个版本解决了啊

SQL

SELECT t.id priceOperationId, t.main_type mainType, t.operate_type operateType, t.price_id priceId, t.hotel_id hotelId, t.roomtype_id roomTypeId, t.rateplan_id ratePlanId, t.begin_date beginDate, t.end_date endDate, t.rateplan_code ratePlanCode, t.gen_salecost genSaleCost, t.gen_saleprice genSalePrice, t.weekend_salecost weekendSaleCost, t.weekend_saleprice weekendSalePrice, t.allow_addbed allowAddBed, t.addbed_price addBedPrice, t.currency_code currencyCode, t.is_priceset isPriceSet, t.is_effective isEffective, t.audit_status auditStatus, t.rate_calculationmodeltype rateCalculationModelType, t.commission_calculationtype commissionCalculationType, t.weekdaycommission_calculationvalue weekdayCommissionCalculationValue, t.weekendcommission_calculationvalue weekendCommissionCalculationValue, t.weekday_netrate weekdayNetRate, t.weekend_netrate weekendNetRate, t.min_profit minProfit, t.max_profit maxProfit, t.create_time createTime, t.creator, t.creator_ip createIp, t.operate_time operateTime, t.operator, t.operate_ip operatorIp, t.price_type priceType
from price_operation_7 t join
(
SELECT auto_id from price_operation_7 b where b.hotel_id = ‘93291826’ and b.roomtype_id = ‘0225’ and b.rateplan_id = 159000751 and b.operate_time < ‘2022-01-19 14:57:43.316’ and b.begin_date <= ‘2022-01-19 00:00:00’ and b.end_date >= ‘2022-01-19 00:00:00’ order by operate_time desc limit 1
) as a on a.auto_id = t.auto_id and t.hotel_id = ‘93291826’ and t.roomtype_id = ‘0225’ and t.rateplan_id = 159000751 limit 1;

栈信息

github.com/pingcap/tidb/server.(*clientConn).Run.func1(0x4048f40, 0xc23375c300, 0xc0f9b4ff00)
	/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/server/conn.go:798 +0xee
panic(0x37d3da0, 0xc09f6d3700)
	/usr/local/go/src/runtime/panic.go:679 +0x1b2
github.com/pingcap/tidb/planner/core.(*joinReOrderSolver).optimizeRecursive(0x5fee320, 0x40a2c00, 0xc0fce16dc0, 0x409de20, 0xc0ef5e2fc0, 0x0, 0x0, 0x0, 0x0)
	/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/core/rule_join_reorder.go:95 +0xa4d
github.com/pingcap/tidb/planner/core.(*joinReOrderSolver).optimizeRecursive(0x5fee320, 0x40a2c00, 0xc0fce16dc0, 0x409df20, 0xc08b0b7960, 0x0, 0x0, 0x0, 0x0)
	/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/core/rule_join_reorder.go:112 +0x894
github.com/pingcap/tidb/planner/core.(*joinReOrderSolver).optimizeRecursive(0x5fee320, 0x40a2c00, 0xc0fce16dc0, 0x409e420, 0xc08b0b77a0, 0xc08b0b7800, 0xc0015d2c30, 0x36f8c20, 0xc0015d2c30)
	/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/core/rule_join_reorder.go:112 +0x894
github.com/pingcap/tidb/planner/core.(*joinReOrderSolver).optimize(0x5fee320, 0x4048f40, 0xc10074c540, 0x409e420, 0xc08b0b77a0, 0x409e420, 0xc08b0b77a0, 0x0, 0x0)
	/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/core/rule_join_reorder.go:58 +0x5a
github.com/pingcap/tidb/planner/core.logicalOptimize(0x4048f40, 0xc10074c540, 0x7142, 0x409df20, 0xc08b0b7880, 0x61e7bf3b, 0xc0deb6a3f8, 0x13e41a6, 0x61e7bf3b)
	/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/core/optimizer.go:235 +0x116
github.com/pingcap/tidb/planner/core.DoOptimize(0x4048f40, 0xc10074c540, 0x40a2c00, 0xc0fce16dc0, 0x7142, 0x409df20, 0xc08b0b7880, 0x0, 0x0, 0x0, …)
	/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/core/optimizer.go:144 +0xb5
github.com/pingcap/tidb/planner.optimize(0x4048f40, 0xc10074c540, 0x40a2c00, 0xc0fce16dc0, 0x4068080, 0xc08afb9300, 0x4094980, 0xc22936aa50, 0x0, 0x0, …)
	/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/optimize.go:288 +0x66c
github.com/pingcap/tidb/planner.Optimize(0x4048f40, 0xc10074c540, 0x40a2c00, 0xc0fce16dc0, 0x4068080, 0xc08afb9300, 0x4094980, 0xc22936aa50, 0x0, 0x0, …)
	/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/planner/optimize.go:124 +0x491
github.com/pingcap/tidb/executor.(*Compiler).Compile(0xc0deb6ad60, 0x4048f40, 0xc10074c540, 0x406fee0, 0xc08afb9300, 0x0, 0x0, 0x0)
	/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/executor/compiler.go:62 +0x294
github.com/pingcap/tidb/session.(*session).ExecuteStmt(0xc0fce16dc0, 0x4048f40, 0xc10074c540, 0x406fee0, 0xc08afb9300, 0x0, 0x0, 0x0, 0x0)
	/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/session/session.go:1433 +0x2c4
github.com/pingcap/tidb/server.(*TiDBContext).ExecuteStmt(0xc23375cba0, 0x4048f40, 0xc10074c540, 0x406fee0, 0xc08afb9300, 0xc095a86bd0, 0x4048f40, 0xc10074c540, 0xc0deb6b130)
	/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/server/driver_tidb.go:218 +0x68
github.com/pingcap/tidb/server.(*clientConn).handleStmt(0xc0f9b4ff00, 0x4048f40, 0xc10074c540, 0x406fee0, 0xc08afb9300, 0x5feea40, 0x0, 0x0, 0x1, 0x0, …)
	/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/server/conn.go:1694 +0x134
github.com/pingcap/tidb/server.(*clientConn).handle

506 已修复

相关 issue 与 pr

https://github.com/pingcap/tidb/issues/24095
https://github.com/pingcap/tidb/pull/24102

1 个赞

:ok_hand:

1 个赞

这是一个bug 好像修复了

:ok_hand:

此话题已在最后回复的 1 分钟后被自动关闭。不再允许新回复。