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执行正常 整个集群运行正常