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

tidb paniced on concurrent inserting invalid value #28190

Closed
ichn-hu opened this issue Sep 18, 2021 · 3 comments · Fixed by #28198
Closed

tidb paniced on concurrent inserting invalid value #28190

ichn-hu opened this issue Sep 18, 2021 · 3 comments · Fixed by #28198
Labels
affects-5.0 This bug affects 5.0.x versions. severity/critical sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@ichn-hu
Copy link
Contributor

ichn-hu commented Sep 18, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

MySQL [test]> show create table t;
+-------+--------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                           |
+-------+--------------------------------------------------------------------------------------------------------+
| t     | CREATE TABLE `t` (
  `t` date DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
+-------+--------------------------------------------------------------------------------------------------------+
1 row in set (0.000 sec)
package main

import (
        "database/sql"
        "fmt"
        "time"

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

func insert(db *sql.DB) {
        for i := 0; i < 1000000; i++ {
                _, err := db.Exec("insert into t values ('')")
                if err != nil {
                        fmt.Println(err)
                }
        }
}

func main() {
        fmt.Println("vim-go")
        // ...

        db, err := sql.Open("mysql", "root:@tcp(127.0.0.1:4000)/test")
        if err != nil {
                panic(err)
        }
        // See "Important settings" section.
        db.SetConnMaxLifetime(time.Minute * 3)
        db.SetMaxOpenConns(10)
        db.SetMaxIdleConns(10)
        go insert(db)
        go insert(db)
        go insert(db)
        go insert(db)
        for {
        }
}

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

error but no panic

3. What did you see instead (Required)

TiDB paniced

goroutine 2789 [running]:
runtime.throw(0x35db4fd, 0x15)
        /home/ichn/.gvm/gos/go1.16/src/runtime/panic.go:1117 +0x72 fp=0xc010dbffa0 sp=0xc010dbff70 pc=0x1042c32
runtime.mapassign_fast64(0x31c01a0, 0xc0004aa690, 0x50c, 0xc0004ac618)
        /home/ichn/.gvm/gos/go1.16/src/runtime/map_fast64.go:101 +0x33e fp=0xc010dbffe0 sp=0xc010dbffa0 pc=0x101d5fe
github.com/pingcap/parser/terror.ErrClass.initError(0x13, 0x50c, 0xc0119a7800, 0xc010dc00e8)
        /home/ichn/.gvm/pkgsets/go1.16/global/pkg/mod/github.com/pingcap/[email protected]/terror/terror.go:156 +0x8d fp=0xc010dc0080 sp=0xc010dbffe0 pc=0x13c46ed
github.com/pingcap/parser/terror.ErrClass.NewStdErr(0x13, 0x50c, 0xc010dc01e0, 0x0)
        /home/ichn/.gvm/pkgsets/go1.16/global/pkg/mod/github.com/pingcap/[email protected]/terror/terror.go:179 +0x3c fp=0xc010dc00f8 sp=0xc010dc0080 pc=0x13c4a3c
github.com/pingcap/tidb/executor.(*InsertValues).handleErr(0xc0115dfd40, 0xc00fb60720, 0xc010dc04d0, 0x0, 0x3a2e0e0, 0xc011907ab8, 0x0, 0x0)
        /home/ichn/Projects/pingcap/tidb-2/executor/insert_common.go:311 +0x768 fp=0xc010dc0398 sp=0xc010dc00f8 pc=0x2bc9588
github.com/pingcap/tidb/executor.(*InsertValues).fastEvalRow(0xc0115dfd40, 0x3a79458, 0xc0119ca0f0, 0xc0119c4290, 0x1, 0x1, 0x0, 0x105b80c, 0x18, 0x30e09a0, ...)
        /home/ichn/Projects/pingcap/tidb-2/executor/insert_common.go:384 +0x45f fp=0xc010dc0570 sp=0xc010dc0398 pc=0x2bcabff
github.com/pingcap/tidb/executor.(*InsertValues).fastEvalRow-fm(0x3a79458, 0xc0119ca0f0, 0xc0119c4290, 0x1, 0x1, 0x0, 0x30, 0x3471e00, 0x60, 0x60, ...)
        /home/ichn/Projects/pingcap/tidb-2/executor/insert_common.go:370 +0x85 fp=0xc010dc05e0 sp=0xc010dc0570 pc=0x2ca1845
github.com/pingcap/tidb/executor.insertRows(0x3a79458, 0xc0119ca0f0, 0x3a551e8, 0xc0119be300, 0x0, 0x136f62a4d6300)
        /home/ichn/Projects/pingcap/tidb-2/executor/insert_common.go:244 +0x223 fp=0xc010dc0718 sp=0xc010dc05e0 pc=0x2bc8783
github.com/pingcap/tidb/executor.(*InsertExec).Next(0xc0119be300, 0x3a79458, 0xc0119ca0f0, 0xc0119a16d0, 0x0, 0xc010dc07b0)
        /home/ichn/Projects/pingcap/tidb-2/executor/insert.go:299 +0x73 fp=0xc010dc0758 sp=0xc010dc0718 pc=0x2bc5c73
github.com/pingcap/tidb/executor.Next(0x3a79458, 0xc0119ca0f0, 0x3a7d498, 0xc0119be300, 0xc0119a16d0, 0x0, 0x0)
        /home/ichn/Projects/pingcap/tidb-2/executor/executor.go:278 +0x2de fp=0xc010dc0878 sp=0xc010dc0758 pc=0x2b7f55e
github.com/pingcap/tidb/executor.(*ExecStmt).handleNoDelayExecutor(0xc0119ae580, 0x3a79458, 0xc0119ca0f0, 0x3a7d498, 0xc0119be300, 0x0, 0x0, 0x0, 0x0)
        /home/ichn/Projects/pingcap/tidb-2/executor/adapter.go:537 +0x2e7 fp=0xc010dc0960 sp=0xc010dc0878 pc=0x2afcaa7
github.com/pingcap/tidb/executor.(*ExecStmt).handleNoDelay(0xc0119ae580, 0x3a79458, 0xc0119ca0f0, 0x3a7d498, 0xc0119be300, 0x5375300, 0x3a79401, 0x0, 0x0, 0x0, ...)
        /home/ichn/Projects/pingcap/tidb-2/executor/adapter.go:418 +0x1e5 fp=0xc010dc09e8 sp=0xc010dc0960 pc=0x2afbb05
github.com/pingcap/tidb/executor.(*ExecStmt).Exec(0xc0119ae580, 0x3a79458, 0xc0119ca0f0, 0x0, 0x0, 0x0, 0x0)
        /home/ichn/Projects/pingcap/tidb-2/executor/adapter.go:368 +0x6bb fp=0xc010dc0b78 sp=0xc010dc09e8 pc=0x2afaf7b
github.com/pingcap/tidb/session.runStmt(0x3a79458, 0xc0119a9dd0, 0xc010c26f00, 0x3a8f150, 0xc0119ae580, 0x0, 0x0, 0x0, 0x0)
        /home/ichn/Projects/pingcap/tidb-2/session/session.go:1560 +0x37f fp=0xc010dc0c78 sp=0xc010dc0b78 pc=0x2cd931f
github.com/pingcap/tidb/session.(*session).ExecuteStmt(0xc010c26f00, 0x3a79458, 0xc0119a9dd0, 0x3a932b8, 0xc0119bab60, 0x0, 0x0, 0x0, 0x0)
        /home/ichn/Projects/pingcap/tidb-2/session/session.go:1455 +0x9a6 fp=0xc010dc1050 sp=0xc010dc0c78 pc=0x2cd81c6
github.com/pingcap/tidb/server.(*TiDBContext).ExecuteStmt(0xc010d86d50, 0x3a79458, 0xc0119a9dd0, 0x3a932b8, 0xc0119bab60, 0xc011984f00, 0x3a79458, 0xc0119a9dd0, 0xc010dc1101)
        /home/ichn/Projects/pingcap/tidb-2/server/driver_tidb.go:218 +0x68 fp=0xc010dc10b8 sp=0xc010dc1050 pc=0x2f57e48
github.com/pingcap/tidb/server.(*clientConn).handleStmt(0xc010b66900, 0x3a793b0, 0xc0119a9dd0, 0x3a932b8, 0xc0119bab60, 0x53a82f0, 0x0, 0x0, 0x1, 0x0, ...)
        /home/ichn/Projects/pingcap/tidb-2/server/conn.go:1694 +0x145 fp=0xc010dc1198 sp=0xc010dc10b8 pc=0x2f4cfe5
github.com/pingcap/tidb/server.(*clientConn).handleQuery(0xc010b66900, 0x3a793b0, 0xc011908880, 0xc0115c1981, 0x19, 0x0, 0x0)
        /home/ichn/Projects/pingcap/tidb-2/server/conn.go:1567 +0x492 fp=0xc010dc12d8 sp=0xc010dc1198 pc=0x2f4b1f2
github.com/pingcap/tidb/server.(*clientConn).dispatch(0xc010b66900, 0x3a793b0, 0xc011908880, 0xc0115c1980, 0x1a, 0x19, 0x0, 0x0)
        /home/ichn/Projects/pingcap/tidb-2/server/conn.go:1101 +0xacf fp=0xc010dc1628 sp=0xc010dc12d8 pc=0x2f465ef
github.com/pingcap/tidb/server.(*clientConn).Run(0xc010b66900, 0x3a79458, 0xc010d18270)
        /home/ichn/Projects/pingcap/tidb-2/server/conn.go:859 +0x296 fp=0xc010dc1e10 sp=0xc010dc1628 pc=0x2f43436
github.com/pingcap/tidb/server.(*Server).onConn(0xc00fc9b790, 0xc010b66900)
        /home/ichn/Projects/pingcap/tidb-2/server/server.go:478 +0xa7e fp=0xc010dc1fd0 sp=0xc010dc1e10 pc=0x2f774be
runtime.goexit()
        /home/ichn/.gvm/gos/go1.16/src/runtime/asm_amd64.s:1371 +0x1 fp=0xc010dc1fd8 sp=0xc010dc1fd0 pc=0x107dd61
created by github.com/pingcap/tidb/server.(*Server).Run
        /home/ichn/Projects/pingcap/tidb-2/server/server.go:381 +0x8d5

this bug is due to #20847 concurrently create new error

4. What is your TiDB version? (Required)

@ichn-hu ichn-hu added the type/bug The issue is confirmed as a bug. label Sep 18, 2021
@ichn-hu
Copy link
Contributor Author

ichn-hu commented Sep 18, 2021

this bug has been fixed on #25405, but has not been cherry picked to 5.0

@bb7133
Copy link
Member

bb7133 commented Sep 18, 2021

Close this issue since the cherry-pick has been done.

@github-actions
Copy link

Please check whether the issue should be labeled with 'affects-x.y' or 'backport-x.y.z',
and then remove 'needs-more-info' label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-5.0 This bug affects 5.0.x versions. severity/critical sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants