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

tiup bench tpch panic when it fails to access tidb #1548

Closed
hhkbp2 opened this issue Sep 2, 2021 · 1 comment · Fixed by #1557
Closed

tiup bench tpch panic when it fails to access tidb #1548

hhkbp2 opened this issue Sep 2, 2021 · 1 comment · Fixed by #1557
Labels
type/bug Categorizes issue as related to a bug.
Milestone

Comments

@hhkbp2
Copy link
Contributor

hhkbp2 commented Sep 2, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?

There is a tidb instance with user test and password properly set. I tried to run tpch benchmark test using following command and then tiup paniced and exited.

tiup bench tpch prepare --host 127.0.0.1 --port 4000 --db test --user test --password --sf 10                         17:31:47  tidb 
Starting component `bench`: /home/dylan/.tiup/components/bench/v1.5.6/tiup-bench tpch prepare --host 127.0.0.1 --port 4000 --db test --user test --password --sf 10
creating nation
panic: runtime error: invalid memory address or nil pointer dereference
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x558efce92404]

goroutine 100 [running]:
database/sql.(*Conn).close(0x0, 0x0, 0x0, 0x0, 0x0)
        database/sql/sql.go:1989 +0x44
database/sql.(*Conn).Close(...)
        database/sql/sql.go:2010
github.com/pingcap/go-tpc/tpch.Workloader.CleanupThread(0x0, 0x558efe8c06e0, 0xc0000d5b80, 0x558efe162000, 0xc000524960, 0x0)
        github.com/pingcap/go-tpc@v1.0.7/tpch/workload.go:98 +0x7f
panic(0x558efe000880, 0x558efe6f8a30)
        runtime/panic.go:965 +0x1b9
database/sql.(*Conn).grabConn(0x0, 0x558efe162000, 0xc000524960, 0xc0000a20d0, 0xc0004320c0, 0x10, 0xc0)
        database/sql/sql.go:1861 +0x28
database/sql.(*Conn).ExecContext(0x0, 0x558efe162000, 0xc000524960, 0x558efd789316, 0xc0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        database/sql/sql.go:1880 +0x4e
github.com/pingcap/go-tpc/tpch.(*Workloader).createTableDDL(0xc000161ba0, 0x558efe162000, 0xc000524960, 0x558efd789316, 0xc0, 0x558efd73ccbf, 0x6, 0x558efd73f7c8, 0x8, 0x0, ...)
        github.com/pingcap/go-tpc@v1.0.7/tpch/ddl.go:17 +0x1c5
github.com/pingcap/go-tpc/tpch.Workloader.createTables(0x0, 0x558efe8c06e0, 0xc0000d5b80, 0x558efe162000, 0xc000524960, 0x7f7abc683780, 0x0)
        github.com/pingcap/go-tpc@v1.0.7/tpch/ddl.go:41 +0x8a
github.com/pingcap/go-tpc/tpch.Workloader.Prepare(0x0, 0x558efe8c06e0, 0xc0000d5b80, 0x558efe162000, 0xc000524960, 0x0, 0x558efe162000, 0xc000524960)
        github.com/pingcap/go-tpc@v1.0.7/tpch/workload.go:106 +0x8e
main.execute(0x558efe161fc8, 0xc000524960, 0x558efe16bed0, 0xc00000cfd8, 0x558efd73e85a, 0x7, 0x0, 0x0, 0x0)
        github.com/tiup/components/bench/misc.go:51 +0x576
main.executeWorkload.func2(0xc00003ce70, 0x558efe161fc8, 0xc0000bd200, 0x558efe16bed0, 0xc00000cfd8, 0x558efd73e85a, 0x7, 0x0)
        github.com/tiup/components/bench/misc.go:104 +0xc5
created by main.executeWorkload
        github.com/tiup/components/bench/misc.go:102 +0x192
Error: run `/home/dylan/.tiup/components/bench/v1.5.6/tiup-bench` (wd:/home/dylan/.tiup/data/ShqR13d) failed: exit status 2
  1. What did you expect to see?

Some clean and nice error message telling that no permission to access the tidb.

  1. What did you see instead?

Rattled and busy stackstrace output due to the panic.

  1. What version of TiUP are you using (tiup --version)?
1.5.6 tiup
Go Version: go1.16.7
Git Ref: v1.5.6
GitHash: 1d1478dbec0d06ef5e909d3323331914538d4cb0

and

tiup-bench v1.5.6

@hhkbp2 hhkbp2 added the type/bug Categorizes issue as related to a bug. label Sep 2, 2021
@hhkbp2 hhkbp2 changed the title tiup bench panic when it fails to access tidb tiup bench tpch panic when it fails to access tidb Sep 2, 2021
@hhkbp2
Copy link
Contributor Author

hhkbp2 commented Sep 2, 2021

The problem is that it initializes a null globalDB handle silently even when error happens at

globalDB = nil

and then the codes of component bench pass down this globalDB to go-tpc/tpch Workloader so the error state propagates all along and the tpch workload codes panic at

https://github.com/pingcap/go-tpc/blob/ae823e848af289e8a8b82b4bc975b1550a961079/tpch/workload.go#L103

without realizing the s.Conn could be nil. Tricky to handle propagated errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Categorizes issue as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants