Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-statements prefetchPointPlanKeys panic #50012

Closed
tangenta opened this issue Jan 3, 2024 · 2 comments · Fixed by #50037
Closed

Multi-statements prefetchPointPlanKeys panic #50012

tangenta opened this issue Jan 3, 2024 · 2 comments · Fixed by #50037
Assignees

Comments

@tangenta
Copy link
Contributor

tangenta commented Jan 3, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

package main

import (
	"context"
	"database/sql"

	_ "github.com/go-sql-driver/mysql"
)

func main() {
	db, err := sql.Open("mysql", "root@tcp(127.0.0.1:4000)/test")
	mustNil(err)
	defer db.Close()
	ctx := context.Background()
	conn, err := db.Conn(ctx)
	mustNil(err)
	defer conn.Close()
	_, err = conn.ExecContext(ctx, "SET tidb_multi_statement_mode='ON';")
	mustNil(err)
	_, err = conn.ExecContext(ctx, "drop table if exists t;")
	mustNil(err)
	_, err = conn.ExecContext(ctx, `CREATE TABLE t (
		a bigint(20),
		b int(10),
		PRIMARY KEY (b, a),
		UNIQUE KEY uk_a (a)
	  );
	  `)
	mustNil(err)

	_, err = conn.ExecContext(ctx, `insert into t values (1, 1);`)
	mustNil(err)

	_, err = conn.ExecContext(ctx, "BEGIN;")
	mustNil(err)
	_, err = conn.QueryContext(ctx, "delete from t where a = 1; select 1;")
	mustNil(err)
}

func mustNil(err error) {
	if err != nil {
		panic(err)
	}
}

2. What did you expect to see? (Required)

1

3. What did you see instead (Required)

Error 1105 (HY000): runtime error: index out of range [7] with length 0
[ERROR] [conn.go:1072] ["connection running loop panic"] [conn=8503385434707984879] [lastSQL="delete from t where a = 1; select 1;"] [err="runtime error: index out of range [7] with length 0"] [stack="github.com/pingcap/tidb/server.(*clientConn).Run.func1\n\t/home/tangenta/tidb/server/conn.go:1075\nruntime.gopanic\n\t/usr/local/go/src/runtime/panic.go:920\nruntime.goPanicIndex\n\t/usr/local/go/src/runtime/panic.go:114\nencoding/binary.bigEndian.Uint64\n\t/usr/local/go/src/encoding/binary/binary.go:179\ngithub.com/pingcap/tidb/tablecodec.DecodeHandleInUniqueIndexValue\n\t/home/tangenta/tidb/tablecodec/tablecodec.go:1650\ngithub.com/pingcap/tidb/server.(*clientConn).prefetchPointPlanKeys\n\t/home/tangenta/tidb/server/conn.go:2063\ngithub.com/pingcap/tidb/server.(*clientConn).handleQuery\n\t/home/tangenta/tidb/server/conn.go:1855\ngithub.com/pingcap/tidb/server.(*clientConn).dispatch\n\t/home/tangenta/tidb/server/conn.go:1372\ngithub.com/pingcap/tidb/server.(*clientConn).Run\n\t/home/tangenta/tidb/server/conn.go:1153\ngithub.com/pingcap/tidb/server.(*Server).onConn\n\t/home/tangenta/tidb/server/server.go:677"]

4. What is your TiDB version? (Required)

v7.1.0, master(33480e8)

@tangenta
Copy link
Contributor Author

tangenta commented Jan 3, 2024

There is no problem with version v6.1.0

@seiya-annie
Copy link

/found customer

@ti-chi-bot ti-chi-bot bot added the report/customer Customers have encountered this bug. label Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants