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

[goleveldb] panic: runtime error: invalid memory address or nil pointer dereference #57

Closed
lunny opened this issue Sep 8, 2015 · 15 comments
Labels
type/bug The issue is confirmed as a bug.

Comments

@lunny
Copy link

lunny commented Sep 8, 2015

When I try to delete, it panic.

[xorm] [info]  2015/09/08 09:35:50.145837 [sql] DELETE FROM `userinfo` WHERE `id` = ? [args] [3]
2015/09/08 09:35:50 tidb.go:97: [debug] compiling prepared DELETE FROM `userinfo` WHERE `id` = ?
2015/09/08 09:35:50 txn.go:108: [debug] get key:142_r   �sdd, txn:94
2015/09/08 09:35:50 tidb.go:97: [debug] compiling prepared DELETE FROM `userinfo` WHERE `id` = ?
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x20 pc=0x411745]

goroutine 201 [running]:
github.com/pingcap/tidb/store/localstore.(*dbSnapshot).Get(0xc820c49ff0, 0xc820e67300, 0x11, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/store/localstore/snapshot.go:34 +0x85
github.com/pingcap/tidb/kv.(*UnionStore).Get(0xc820c5c120, 0xc820e67300, 0x11, 0x20, 0x0, 0x0, 0x0, 0x1b00000, 0xc820061210)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/kv/union_store.go:91 +0x11c
github.com/pingcap/tidb/store/localstore.(*dbTxn).Get(0xc820c5c120, 0xc820e67300, 0x11, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/store/localstore/txn.go:110 +0x34a
github.com/pingcap/tidb/table/tables.(*Table).RowWithCols(0xc82045d5f0, 0x1b82050, 0xc820018180, 0x9, 0xc8204208c0, 0x8, 0x8, 0x0, 0x0, 0x0, ...)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/table/tables/tables.go:412 +0x23d
github.com/pingcap/tidb/table/tables.(*Table).Row(0xc82045d5f0, 0x1b82050, 0xc820018180, 0x9, 0x0, 0x0, 0x0, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/table/tables/tables.go:430 +0xce
github.com/pingcap/tidb/plan/plans.(*TableDefaultPlan).Do(0xc820c46e70, 0x1b82050, 0xc820018180, 0xc820222640, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/plan/plans/from.go:283 +0x3d1
github.com/pingcap/tidb/plan/plans.(*JoinPlan).Do(0xc820019f80, 0x1b82050, 0xc820018180, 0xc820222640, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/plan/plans/join.go:140 +0x6e
github.com/pingcap/tidb/plan/plans.(*FilterDefaultPlan).Do(0xc820c4e840, 0x1b82050, 0xc820018180, 0xc820c46fc0, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/plan/plans/where.go:72 +0x1ad
github.com/pingcap/tidb/plan/plans.(*SelectLockPlan).Do(0xc820c4e880, 0x1b82050, 0xc820018180, 0xc820c46f90, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/plan/plans/lock.go:63 +0xd7
github.com/pingcap/tidb/plan/plans.(*LimitDefaultPlan).Do(0xc820c46f60, 0x1b82050, 0xc820018180, 0xc820c4e980, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/plan/plans/limit.go:69 +0x103
github.com/pingcap/tidb/plan/plans.(*SelectFinalPlan).Do(0xc820c4e8e0, 0x1b82050, 0xc820018180, 0xc820c49fb0, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/plan/plans/final.go:59 +0xc4
github.com/pingcap/tidb/rset/rsets.Recordset.Do(0x1b82050, 0xc820018180, 0x1b82e58, 0xc820c4e8e0, 0xc820c49fa0, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/rset/rsets/rsets.go:42 +0x97
github.com/pingcap/tidb/rset/rsets.(*Recordset).Do(0xc820c4e900, 0xc820c49fa0, 0x0, 0x0)
    <autogenerated>:6 +0xac
github.com/pingcap/tidb.newdriverRows.func1(0xc820c4e920)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/driver.go:355 +0xa9
created by github.com/pingcap/tidb.newdriverRows
    /Users/lunny/gopath/src/github.com/pingcap/tidb/driver.go:374 +0xeb

goroutine 1 [chan receive]:
testing.RunTests(0xa13c40, 0xd70b20, 0x2, 0x2, 0x1)
    /Users/lunny/go1.5/src/testing/testing.go:562 +0x8ad
testing.(*M).Run(0xc820039f08, 0xc8201d1e60)
    /Users/lunny/go1.5/src/testing/testing.go:494 +0x70
main.main()
    github.com/go-xorm/tidb/_test/_testmain.go:72 +0x116

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
    /Users/lunny/go1.5/src/runtime/asm_amd64.s:1696 +0x1

goroutine 20 [IO wait]:
net.runtime_pollWait(0x1b81050, 0x72, 0xc820060080)
    /Users/lunny/go1.5/src/runtime/netpoll.go:157 +0x60
net.(*pollDesc).Wait(0xc820698060, 0x72, 0x0, 0x0)
    /Users/lunny/go1.5/src/net/fd_poll_runtime.go:73 +0x3a
net.(*pollDesc).WaitRead(0xc820698060, 0x0, 0x0)
    /Users/lunny/go1.5/src/net/fd_poll_runtime.go:78 +0x36
net.(*netFD).accept(0xc820698000, 0x0, 0x1b81148, 0xc8206920a0)
    /Users/lunny/go1.5/src/net/fd_unix.go:408 +0x27c
net.(*TCPListener).AcceptTCP(0xc820230008, 0xc820057dd0, 0x0, 0x0)
    /Users/lunny/go1.5/src/net/tcpsock_posix.go:254 +0x4d
net/http.tcpKeepAliveListener.Accept(0xc820230008, 0x0, 0x0, 0x0, 0x0)
    /Users/lunny/go1.5/src/net/http/server.go:2135 +0x41
net/http.(*Server).Serve(0xc820214000, 0x1b81110, 0xc820230008, 0x0, 0x0)
    /Users/lunny/go1.5/src/net/http/server.go:1887 +0xb3
net/http.(*Server).ListenAndServe(0xc820214000, 0x0, 0x0)
    /Users/lunny/go1.5/src/net/http/server.go:1877 +0x136
net/http.ListenAndServe(0x8c06d0, 0xe, 0x0, 0x0, 0x0, 0x0)
    /Users/lunny/go1.5/src/net/http/server.go:1967 +0x8f
created by github.com/pingcap/tidb.init.2
    /Users/lunny/gopath/src/github.com/pingcap/tidb/tidb.go:262 +0x1a6
@shenli
Copy link
Member

shenli commented Sep 8, 2015

May I have your command log?
When I run go test in go-xorm/tidb, I meet another error.

Thanks for your report! I will work on this.

@coocood coocood added the type/bug The issue is confirmed as a bug. label Sep 8, 2015
@lunny
Copy link
Author

lunny commented Sep 8, 2015

@shenli, please go get -u github.com/go-xorm/tidb. I have resolved some problems. This is the lastest one.

And then go test, the detail log is below.

-------------- testDelete --------------
[xorm] [info]  2015/09/08 12:34:34.891102 [sql] DELETE FROM `userinfo` WHERE `id` = ? [args] [1]
2015/09/08 12:34:34 tidb.go:97: [debug] compiling prepared DELETE FROM `userinfo` WHERE `id` = ?
2015/09/08 12:34:34 delete.go:157: [info] try delete with index %!v(PANIC=runtime error: invalid memory address or nil pointer dereference)
2015/09/08 12:34:34 kv.go:115: [debug] Begin txn:93
2015/09/08 12:34:34 session.go:201: [warning] New txn:93 in session:1
2015/09/08 12:34:34 txn.go:138: [debug] seek 202_rsd txn:93
2015/09/08 12:34:34 tables.go:538: [debug] startKey 202_rsd, key:202_rsd,value:63
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:160: [debug] delete 202_i_primaryd txn:93
2015/09/08 12:34:34 txn.go:160: [debug] delete 202_i_uqe_userinfo_usernamexiaolunwens txn:93
2015/09/08 12:34:34 txn.go:160: [debug] delete 202_r�sdd txn:93
2015/09/08 12:34:34 txn.go:160: [debug] delete 202_r�sdd txn:93
2015/09/08 12:34:34 txn.go:160: [debug] delete 202_r�sdd txn:93
2015/09/08 12:34:34 txn.go:160: [debug] delete 202_r�sdd txn:93
2015/09/08 12:34:34 txn.go:160: [debug] delete 202_r�sdd txn:93
2015/09/08 12:34:34 txn.go:160: [debug] delete 202_r�sdd txn:93
2015/09/08 12:34:34 txn.go:160: [debug] delete 202_r�sdd txn:93
2015/09/08 12:34:34 txn.go:160: [debug] delete 202_r�sdd txn:93
2015/09/08 12:34:34 txn.go:160: [debug] delete 202_rsd txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r   �sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r   �sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r   �sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r   �sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r   �sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r   �sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r   �sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r   �sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r
�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r
�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r
�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r
�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r
�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r
�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r
�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r
�sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r
                                                     �sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r
                                                     �sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r
                                                     �sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r
                                                     �sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r
                                                     �sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r
                                                     �sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r
                                                     �sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r
                                                     �sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r
                                                     �sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r
                                                     �sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r
                                                     �sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r
                                                     �sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r
                                                     �sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r
                                                     �sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r
                                                     �sdd, txn:93
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r
                                                     �sdd, txn:93
2015/09/08 12:34:34 txn.go:213: [info] commit txn 93
[xorm] [debug] 2015/09/08 12:34:34.894226 [time] DELETE FROM `userinfo` WHERE `id` = ? - args [1] - execution took: 3100580ns
[xorm] [info]  2015/09/08 12:34:34.894378 [sql] SELECT `id`, `username`, `departname`, `created`, `detail_id`, `height`, `avatar`, `is_man` FROM `userinfo` WHERE `id` = ? LIMIT 1 [args] [3]
2015/09/08 12:34:34 tidb.go:97: [debug] compiling prepared SELECT `id`, `username`, `departname`, `created`, `detail_id`, `height`, `avatar`, `is_man` FROM `userinfo` WHERE `id` = ? LIMIT 1
2015/09/08 12:34:34 select.go:205: [info] SelectStmt trx:
2015/09/08 12:34:34 kv.go:115: [debug] Begin txn:94
2015/09/08 12:34:34 session.go:201: [warning] New txn:94 in session:1
2015/09/08 12:34:34 txn.go:138: [debug] seek 202_rsd txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
[xorm] [debug] 2015/09/08 12:34:34.895451 time(4) key[Created]: 2015-09-08 12:34:34 +0800 CST | sdata: [2015-09-08 12:34:34]
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
[xorm] [info]  2015/09/08 12:34:34.895923 [sql] SELECT `id`, `intro`, `profile` FROM `userdetail` WHERE `id` = ? LIMIT 1 [args] [1]
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 kv.go:71: [info] cache store ./tidb
2015/09/08 12:34:34 tidb.go:84: [debug] compiling use tidb
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 tidb.go:97: [debug] compiling prepared SELECT `id`, `intro`, `profile` FROM `userdetail` WHERE `id` = ? LIMIT 1
2015/09/08 12:34:34 select.go:205: [info] SelectStmt trx:
2015/09/08 12:34:34 kv.go:115: [debug] Begin txn:95
2015/09/08 12:34:34 session.go:201: [warning] New txn:95 in session:2
2015/09/08 12:34:34 txn.go:138: [debug] seek 206_rsd txn:95
2015/09/08 12:34:34 txn.go:108: [debug] get key:206_r�sdd, txn:95
2015/09/08 12:34:34 txn.go:108: [debug] get key:206_r�sdd, txn:95
2015/09/08 12:34:34 txn.go:108: [debug] get key:206_r�sdd, txn:95
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
[xorm] [info]  2015/09/08 12:34:34.896848 [sql] SELECT `id`, `intro`, `profile` FROM `userdetail` WHERE `id` = ? LIMIT 1 [args] [1]
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 tidb.go:97: [debug] compiling prepared SELECT `id`, `intro`, `profile` FROM `userdetail` WHERE `id` = ? LIMIT 1
2015/09/08 12:34:34 select.go:205: [info] SelectStmt trx:
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:213: [info] commit txn 95
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_�sdd, txn:94
2015/09/08 12:34:34 kv.go:115: [debug] Begin txn:96
2015/09/08 12:34:34 session.go:201: [warning] New txn:96 in session:2
2015/09/08 12:34:34 txn.go:138: [debug] seek 206_rsd txn:96
2015/09/08 12:34:34 txn.go:108: [debug] get key:206_r�sdd, txn:96
2015/09/08 12:34:34 txn.go:108: [debug] get key:206_r�sdd, txn:96
2015/09/08 12:34:34 txn.go:108: [debug] get key:206_r�sdd, txn:96
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_�sdd, txn:94
2015/09/08 12:34:34 txn.go:213: [info] commit txn 96
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_�sdd, txn:94
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_�sdd, txn:94
2015/09/08 12:34:34 txn.go:213: [info] commit txn 94
[xorm] [info]  2015/09/08 12:34:34.897616 [sql] DELETE FROM `userinfo` WHERE `id` = ? [args] [3]
2015/09/08 12:34:34 tidb.go:97: [debug] compiling prepared DELETE FROM `userinfo` WHERE `id` = ?
2015/09/08 12:34:34 tidb.go:97: [debug] compiling prepared DELETE FROM `userinfo` WHERE `id` = ?
2015/09/08 12:34:34 delete.go:157: [info] try delete with index %!v(PANIC=runtime error: invalid memory address or nil pointer dereference)
2015/09/08 12:34:34 kv.go:115: [debug] Begin txn:97
2015/09/08 12:34:34 session.go:201: [warning] New txn:97 in session:1
2015/09/08 12:34:34 txn.go:138: [debug] seek 202_rsd txn:97
2015/09/08 12:34:34 tables.go:538: [debug] startKey 202_rsd, key:202_rsd,value:87
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:97
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:97
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:97
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:97
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:97
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:97
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:97
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r�sdd, txn:97
2015/09/08 12:34:34 txn.go:108: [debug] get key:202_r   �sdd, txn:94
2015/09/08 12:34:34 txn.go:160: [debug] delete 202_i_primaryd txn:97
2015/09/08 12:34:34 txn.go:160: [debug] delete 202_i_uqe_userinfo_usernamexiaolunwen2s txn:97
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x20 pc=0x411745]

goroutine 236 [running]:
github.com/pingcap/tidb/store/localstore.(*dbSnapshot).Get(0xc820b21c80, 0xc8205e0580, 0x11, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/store/localstore/snapshot.go:34 +0x85
github.com/pingcap/tidb/kv.(*UnionStore).Get(0xc8205c8060, 0xc8205e0580, 0x11, 0x20, 0x0, 0x0, 0x0, 0x19b0028, 0xc82000b320)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/kv/union_store.go:91 +0x11c
github.com/pingcap/tidb/store/localstore.(*dbTxn).Get(0xc8205c8060, 0xc8205e0580, 0x11, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/store/localstore/txn.go:110 +0x34a
github.com/pingcap/tidb/table/tables.(*Table).RowWithCols(0xc820188fc0, 0x1c80bf0, 0xc82017ac00, 0x9, 0xc8206d2280, 0x8, 0x8, 0x0, 0x0, 0x0, ...)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/table/tables/tables.go:412 +0x23d
github.com/pingcap/tidb/table/tables.(*Table).Row(0xc820188fc0, 0x1c80bf0, 0xc82017ac00, 0x9, 0x0, 0x0, 0x0, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/table/tables/tables.go:430 +0xce
github.com/pingcap/tidb/plan/plans.(*TableDefaultPlan).Do(0xc820b245a0, 0x1c80bf0, 0xc82017ac00, 0xc820c50280, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/plan/plans/from.go:283 +0x3d1
github.com/pingcap/tidb/plan/plans.(*JoinPlan).Do(0xc8201e9ec0, 0x1c80bf0, 0xc82017ac00, 0xc820c50280, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/plan/plans/join.go:140 +0x6e
github.com/pingcap/tidb/plan/plans.(*FilterDefaultPlan).Do(0xc820b23020, 0x1c80bf0, 0xc82017ac00, 0xc820b246f0, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/plan/plans/where.go:72 +0x1ad
github.com/pingcap/tidb/plan/plans.(*SelectLockPlan).Do(0xc820b23060, 0x1c80bf0, 0xc82017ac00, 0xc820b246c0, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/plan/plans/lock.go:63 +0xd7
github.com/pingcap/tidb/plan/plans.(*LimitDefaultPlan).Do(0xc820b24690, 0x1c80bf0, 0xc82017ac00, 0xc820b23160, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/plan/plans/limit.go:69 +0x103
github.com/pingcap/tidb/plan/plans.(*SelectFinalPlan).Do(0xc820b230c0, 0x1c80bf0, 0xc82017ac00, 0xc820b21c40, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/plan/plans/final.go:59 +0xc4
github.com/pingcap/tidb/rset/rsets.Recordset.Do(0x1c80bf0, 0xc82017ac00, 0x1c818b8, 0xc820b230c0, 0xc820b21c30, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/rset/rsets/rsets.go:42 +0x97
github.com/pingcap/tidb/rset/rsets.(*Recordset).Do(0xc820b230e0, 0xc820b21c30, 0x0, 0x0)
    <autogenerated>:6 +0xac
github.com/pingcap/tidb.newdriverRows.func1(0xc820b23100)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/driver.go:355 +0xa9
created by github.com/pingcap/tidb.newdriverRows
    /Users/lunny/gopath/src/github.com/pingcap/tidb/driver.go:374 +0xeb

goroutine 1 [chan receive]:
testing.RunTests(0xa13c40, 0xd70b20, 0x2, 0x2, 0x1)
    /Users/lunny/go1.5/src/testing/testing.go:562 +0x8ad
testing.(*M).Run(0xc82069ff08, 0xc820234120)
    /Users/lunny/go1.5/src/testing/testing.go:494 +0x70
main.main()
    github.com/go-xorm/tidb/_test/_testmain.go:72 +0x116

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
    /Users/lunny/go1.5/src/runtime/asm_amd64.s:1696 +0x1

goroutine 50 [select]:
github.com/syndtr/goleveldb/leveldb.(*DB).compactionError(0xc82026a000)
    /Users/lunny/gopath/src/github.com/syndtr/goleveldb/leveldb/db_compaction.go:69 +0x54a
created by github.com/syndtr/goleveldb/leveldb.openDB
    /Users/lunny/gopath/src/github.com/syndtr/goleveldb/leveldb/db.go:139 +0x77f

goroutine 18 [IO wait]:
net.runtime_pollWait(0x19b5d80, 0x72, 0xc82000a190)
    /Users/lunny/go1.5/src/runtime/netpoll.go:157 +0x60
net.(*pollDesc).Wait(0xc82005e450, 0x72, 0x0, 0x0)
    /Users/lunny/go1.5/src/net/fd_poll_runtime.go:73 +0x3a
net.(*pollDesc).WaitRead(0xc82005e450, 0x0, 0x0)
    /Users/lunny/go1.5/src/net/fd_poll_runtime.go:78 +0x36
net.(*netFD).accept(0xc82005e3f0, 0x0, 0x19b5e78, 0xc820011320)
    /Users/lunny/go1.5/src/net/fd_unix.go:408 +0x27c
net.(*TCPListener).AcceptTCP(0xc82002a088, 0xc82005ddd0, 0x0, 0x0)
    /Users/lunny/go1.5/src/net/tcpsock_posix.go:254 +0x4d
net/http.tcpKeepAliveListener.Accept(0xc82002a088, 0x0, 0x0, 0x0, 0x0)
    /Users/lunny/go1.5/src/net/http/server.go:2135 +0x41
net/http.(*Server).Serve(0xc820018300, 0x19b5e40, 0xc82002a088, 0x0, 0x0)
    /Users/lunny/go1.5/src/net/http/server.go:1887 +0xb3
net/http.(*Server).ListenAndServe(0xc820018300, 0x0, 0x0)
    /Users/lunny/go1.5/src/net/http/server.go:1877 +0x136
net/http.ListenAndServe(0x8c06d0, 0xe, 0x0, 0x0, 0x0, 0x0)
    /Users/lunny/go1.5/src/net/http/server.go:1967 +0x8f
created by github.com/pingcap/tidb.init.2
    /Users/lunny/gopath/src/github.com/pingcap/tidb/tidb.go:262 +0x1a6

goroutine 19 [runnable]:
github.com/syndtr/goleveldb/leveldb/comparer.(*bytesComparer).Compare(0xdbc1b0, 0xc820714dd9, 0x11, 0x3d1227, 0xc820f90400, 0xe, 0x16, 0xffffffffffffffff)
    <autogenerated>:1
github.com/syndtr/goleveldb/leveldb.(*iComparer).Compare(0xc8202331a0, 0xc820714dd9, 0x19, 0x3d1227, 0xc820f90400, 0x16, 0x16, 0xffffffffffffffff)
    /Users/lunny/gopath/src/github.com/syndtr/goleveldb/leveldb/comparer.go:36 +0x117
github.com/syndtr/goleveldb/leveldb/memdb.(*DB).findGE(0xc8202461c0, 0xc820f90400, 0x16, 0x16, 0x52100, 0xc820f84348, 0xc820f84350)
    /Users/lunny/gopath/src/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go:218 +0x174
github.com/syndtr/goleveldb/leveldb/memdb.(*DB).Find(0xc8202461c0, 0xc820f90400, 0x16, 0x16, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /Users/lunny/gopath/src/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go:375 +0xaf
github.com/syndtr/goleveldb/leveldb.(*DB).get(0xc82026a000, 0xc820f922c0, 0xe, 0x10, 0x699, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /Users/lunny/gopath/src/github.com/syndtr/goleveldb/leveldb/db.go:740 +0x2c3
github.com/syndtr/goleveldb/leveldb.(*Snapshot).Get(0xc8205f28d0, 0xc820f922c0, 0xe, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/syndtr/goleveldb/leveldb/db_snapshot.go:113 +0x1a6
github.com/pingcap/tidb/store/localstore/goleveldb.(*snapshot).Get(0xc8204b4ce0, 0xc820f922c0, 0xe, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/store/localstore/goleveldb/goleveldb.go:87 +0x87
github.com/pingcap/tidb/store/localstore.(*dbSnapshot).Get(0xc8205e3a10, 0xc820f922c0, 0xe, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/store/localstore/snapshot.go:34 +0x8b
github.com/pingcap/tidb/store/localstore.(*dbTxn).markOrigin(0xc820b7f380, 0xc820f922c0, 0xe, 0x10, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/store/localstore/txn.go:56 +0x12d
github.com/pingcap/tidb/store/localstore.(*dbTxn).LockKeys(0xc820b7f380, 0xc820f903e0, 0x1, 0x1, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/store/localstore/txn.go:239 +0x203
github.com/pingcap/tidb/table/tables.(*Table).LockRow(0xc820188fc0, 0x1c80bf0, 0xc82017ac00, 0x3, 0x63db00, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/table/tables/tables.go:445 +0x198
github.com/pingcap/tidb/table/tables.(*Table).RemoveRow(0xc820188fc0, 0x1c80bf0, 0xc82017ac00, 0x3, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/table/tables/tables.go:459 +0x6e
github.com/pingcap/tidb/stmt/stmts.(*DeleteStmt).removeRow(0xc8205e6280, 0x1c80bf0, 0xc82017ac00, 0x1c80ad8, 0xc820188fc0, 0x3, 0xc8205f4380, 0x8, 0x8, 0x0, ...)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/stmt/stmts/delete.go:149 +0x101
github.com/pingcap/tidb/stmt/stmts.(*DeleteStmt).Exec.func1(0x3, 0xc8205f4380, 0x8, 0x8, 0xc8206d2280, 0x8, 0x8, 0xc8205f4380, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/stmt/stmts/delete.go:232 +0x232
github.com/pingcap/tidb/table/tables.(*Table).IterRecords(0xc820188fc0, 0x1c80bf0, 0xc82017ac00, 0xc8205e39e0, 0xc, 0xc8206d2280, 0x8, 0x8, 0xc820013ae0, 0x0, ...)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/table/tables/tables.go:555 +0x693
github.com/pingcap/tidb/stmt/stmts.(*DeleteStmt).Exec(0xc8205e6280, 0x1c80bf0, 0xc82017ac00, 0x0, 0x0, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/stmt/stmts/delete.go:238 +0x5c1
github.com/pingcap/tidb/stmt/stmts.(*ExecuteStmt).Exec(0xc820c37640, 0x1c80bf0, 0xc82017ac00, 0x0, 0x0, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/stmt/stmts/prepared.go:235 +0x75d
github.com/pingcap/tidb.runExecute(0x1c80bf0, 0xc82017ac00, 0xc820c37640, 0xc8205e3850, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/tidb.go:176 +0x248
github.com/pingcap/tidb.runStmt(0x1c80bf0, 0xc82017ac00, 0x1c81988, 0xc820c37640, 0xc8205e3850, 0x1, 0x1, 0x0, 0x0, 0x0, ...)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/tidb.go:144 +0x224
github.com/pingcap/tidb.executePreparedStmt(0x1c80bf0, 0xc82017ac00, 0x24, 0xc8205e3850, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/tidb.go:124 +0xec
github.com/pingcap/tidb.(*session).ExecutePreparedStmt(0xc82017ac00, 0x24, 0xc8205e3850, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/session.go:179 +0x115
github.com/pingcap/tidb.(*driverStmt).Exec(0xc8205f2810, 0xc8205e3830, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/driver.go:490 +0xf0
database/sql.resultFromStatement(0x1c81360, 0xc82017b500, 0x1c818f8, 0xc8205f2810, 0xc8205e34e0, 0x1, 0x1, 0x0, 0x0, 0x0, ...)
    /Users/lunny/go1.5/src/database/sql/sql.go:1383 +0x3bd
database/sql.(*Stmt).Exec(0xc8205f4100, 0xc8205e34e0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0)
    /Users/lunny/go1.5/src/database/sql/sql.go:1356 +0x2ae
github.com/go-xorm/xorm.(*Session).innerExec(0xc820d7d400, 0xc8205f2630, 0x25, 0xc8205e34e0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/go-xorm/xorm/session.go:468 +0xd0
github.com/go-xorm/xorm.(*Session).exec.func1(0x0, 0x0, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/go-xorm/xorm/session.go:491 +0x219
github.com/go-xorm/xorm.(*Engine).LogSQLExecutionTime(0xc820188c60, 0xc8205f2630, 0x25, 0x6702a0, 0xc8205dbbc0, 0xc820f856a0, 0x0, 0x0, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/go-xorm/xorm/engine.go:222 +0x8b
github.com/go-xorm/xorm.(*Session).exec(0xc820d7d400, 0xc8205f2630, 0x25, 0xc8205e34e0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/go-xorm/xorm/session.go:494 +0x2de
github.com/go-xorm/xorm.(*Session).Delete(0xc820d7d400, 0x6572e0, 0xc8205e60a0, 0x0, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/go-xorm/xorm/session.go:3919 +0x163d
github.com/go-xorm/tests.testDelete(0xc820188c60, 0xc820188bd0)
    /Users/lunny/gopath/src/github.com/go-xorm/tests/testDelete.go:32 +0x5e8
github.com/go-xorm/tests.BaseTestAll(0xc820188c60, 0xc820188bd0)
    /Users/lunny/gopath/src/github.com/go-xorm/tests/base.go:623 +0x73e
github.com/go-xorm/tidb.TestTidbNoCache(0xc820188bd0)
    /Users/lunny/gopath/src/github.com/go-xorm/tidb/tidb_test.go:50 +0x161
testing.tRunner(0xc820188bd0, 0xd70b20)
    /Users/lunny/go1.5/src/testing/testing.go:456 +0x98
created by testing.RunTests
    /Users/lunny/go1.5/src/testing/testing.go:561 +0x86d

goroutine 20 [chan receive]:
database/sql.(*DB).connectionOpener(0xc82020a280)
    /Users/lunny/go1.5/src/database/sql/sql.go:634 +0x45
created by database/sql.Open
    /Users/lunny/go1.5/src/database/sql/sql.go:481 +0x336

goroutine 21 [select]:
github.com/syndtr/goleveldb/leveldb/util.(*BufferPool).drain(0xc820246000)
    /Users/lunny/gopath/src/github.com/syndtr/goleveldb/leveldb/util/buffer_pool.go:206 +0x29d
created by github.com/syndtr/goleveldb/leveldb/util.NewBufferPool
    /Users/lunny/gopath/src/github.com/syndtr/goleveldb/leveldb/util/buffer_pool.go:237 +0x26b

goroutine 51 [select]:
github.com/syndtr/goleveldb/leveldb.(*DB).mpoolDrain(0xc82026a000)
    /Users/lunny/gopath/src/github.com/syndtr/goleveldb/leveldb/db_state.go:82 +0x14b
created by github.com/syndtr/goleveldb/leveldb.openDB
    /Users/lunny/gopath/src/github.com/syndtr/goleveldb/leveldb/db.go:140 +0x7a1

goroutine 35 [select]:
github.com/syndtr/goleveldb/leveldb.(*DB).tCompaction(0xc82026a000)
    /Users/lunny/gopath/src/github.com/syndtr/goleveldb/leveldb/db_compaction.go:768 +0x7c8
created by github.com/syndtr/goleveldb/leveldb.openDB
    /Users/lunny/gopath/src/github.com/syndtr/goleveldb/leveldb/db.go:146 +0x9a5

goroutine 36 [select]:
github.com/syndtr/goleveldb/leveldb.(*DB).mCompaction(0xc82026a000)
    /Users/lunny/gopath/src/github.com/syndtr/goleveldb/leveldb/db_compaction.go:715 +0x253
created by github.com/syndtr/goleveldb/leveldb.openDB
    /Users/lunny/gopath/src/github.com/syndtr/goleveldb/leveldb/db.go:147 +0x9c7

goroutine 37 [select]:
github.com/syndtr/goleveldb/leveldb.(*DB).jWriter(0xc82026a000)
    /Users/lunny/gopath/src/github.com/syndtr/goleveldb/leveldb/db_write.go:37 +0x1a2
created by github.com/syndtr/goleveldb/leveldb.openDB
    /Users/lunny/gopath/src/github.com/syndtr/goleveldb/leveldb/db.go:148 +0x9e9
exit status 2
FAIL    github.com/go-xorm/tidb 0.475s

@shenli
Copy link
Member

shenli commented Sep 8, 2015

@lunny please check the latest code and have a test.
We fix a bug about prepared statement panic. But I do not encounter the same error as you reported.
I meet a few other errors when run go test in go-xorm/tidb and I am working on those bugs.

Thanks!

@unknwon
Copy link
Contributor

unknwon commented Sep 8, 2015

Runtime here too, just updated my tidb:

2015/09/08 06:00:33 tidb.go:101: [debug] compiling prepared SELECT `id`, `lower_name`, `name`, `full_name`, `email`, `passwd`, `login_type`, `login_source`, `login_name`, `type`, `location`, `website`, `rands`, `salt`, `created`, `updated`, `last_repo_visibility`, `is_active`, `is_admin`, `allow_git_hook`, `avatar`, `avatar_email`, `use_custom_avatar`, `num_followers`, `num_followings`, `num_stars`, `num_repos`, `description`, `num_teams`, `num_members` FROM `user` WHERE `id` = ? LIMIT 1
2015/09/08 06:00:33 txn.go:108: [debug] get key:35_r�sdd, txn:10
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x20 pc=0x494c535]

goroutine 274 [running]:
github.com/pingcap/tidb/store/localstore.(*dbSnapshot).Get(0xc8200130b0, 0xc82144f580, 0x11, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0)
    /Users/unknwon/Applications/Go/src/github.com/pingcap/tidb/store/localstore/snapshot.go:34 +0x85
github.com/pingcap/tidb/kv.(*UnionStore).Get(0xc820309e60, 0xc82144f580, 0x11, 0x20, 0x0, 0x0, 0x0, 0x6260000, 0xc820258820)
    /Users/unknwon/Applications/Go/src/github.com/pingcap/tidb/kv/union_store.go:91 +0x11c
github.com/pingcap/tidb/store/localstore.(*dbTxn).Get(0xc820309e60, 0xc82144f580, 0x11, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0)
    /Users/unknwon/Applications/Go/src/github.com/pingcap/tidb/store/localstore/txn.go:110 +0x34a
github.com/pingcap/tidb/table/tables.(*Table).RowWithCols(0xc8200ac240, 0x7940408, 0xc820074240, 0x3e9, 0xc8200e2300, 0x1e, 0x20, 0x0, 0x0, 0x0, ...)
    /Users/unknwon/Applications/Go/src/github.com/pingcap/tidb/table/tables/tables.go:416 +0x23d
github.com/pingcap/tidb/table/tables.(*Table).Row(0xc8200ac240, 0x7940408, 0xc820074240, 0x3e9, 0x0, 0x0, 0x0, 0x0, 0x0)
    /Users/unknwon/Applications/Go/src/github.com/pingcap/tidb/table/tables/tables.go:434 +0xce
github.com/pingcap/tidb/plan/plans.(*TableDefaultPlan).Do(0xc8203c90e0, 0x7940408, 0xc820074240, 0xc821290410, 0x0, 0x0)
    /Users/unknwon/Applications/Go/src/github.com/pingcap/tidb/plan/plans/from.go:287 +0x3d1
github.com/pingcap/tidb/plan/plans.(*JoinPlan).Do(0xc820309320, 0x7940408, 0xc820074240, 0xc821290410, 0x0, 0x0)
    /Users/unknwon/Applications/Go/src/github.com/pingcap/tidb/plan/plans/join.go:144 +0x6e
github.com/pingcap/tidb/plan/plans.(*FilterDefaultPlan).Do(0xc8213e6860, 0x7940408, 0xc820074240, 0xc8203c9830, 0x0, 0x0)
    /Users/unknwon/Applications/Go/src/github.com/pingcap/tidb/plan/plans/where.go:76 +0x1ad
github.com/pingcap/tidb/plan/plans.(*SelectLockPlan).Do(0xc8213e68e0, 0x7940408, 0xc820074240, 0xc8203c9680, 0x0, 0x0)
    /Users/unknwon/Applications/Go/src/github.com/pingcap/tidb/plan/plans/lock.go:63 +0xd7
github.com/pingcap/tidb/plan/plans.(*LimitDefaultPlan).Do(0xc8203c9590, 0x7940408, 0xc820074240, 0xc8213e6ae0, 0x0, 0x0)
    /Users/unknwon/Applications/Go/src/github.com/pingcap/tidb/plan/plans/limit.go:73 +0x103
github.com/pingcap/tidb/plan/plans.(*SelectFinalPlan).Do(0xc8213e69a0, 0x7940408, 0xc820074240, 0xc820013040, 0x0, 0x0)
    /Users/unknwon/Applications/Go/src/github.com/pingcap/tidb/plan/plans/final.go:59 +0xc4
github.com/pingcap/tidb/rset/rsets.Recordset.Do(0x7940408, 0xc820074240, 0x79409d0, 0xc8213e69a0, 0xc820013030, 0x0, 0x0)
    /Users/unknwon/Applications/Go/src/github.com/pingcap/tidb/rset/rsets/rsets.go:46 +0x97
github.com/pingcap/tidb/rset/rsets.(*Recordset).Do(0xc8213e69e0, 0xc820013030, 0x0, 0x0)
    <autogenerated>:6 +0xac
github.com/pingcap/tidb.newdriverRows.func1(0xc8213e6a20)
    /Users/unknwon/Applications/Go/src/github.com/pingcap/tidb/driver.go:368 +0xa9
created by github.com/pingcap/tidb.newdriverRows
    /Users/unknwon/Applications/Go/src/github.com/pingcap/tidb/driver.go:387 +0xeb

@lunny
Copy link
Author

lunny commented Sep 8, 2015

The similar problem here.

[xorm] [info]  2015/09/08 18:06:20.638850 [sql] SELECT * FROM `userinfo` LEFT JOIN `userdetail` ON `userinfo`.`detail_id` = `userdetail`.`id` LIMIT 1
2015/09/08 18:06:20 txn.go:108: [debug] get key:36_r�sdd, txn:442
2015/09/08 18:06:20 tidb.go:101: [debug] compiling prepared SELECT * FROM `userinfo` LEFT JOIN `userdetail` ON `userinfo`.`detail_id` = `userdetail`.`id` LIMIT 1
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x20 pc=0x411b15]

goroutine 342 [running]:
github.com/pingcap/tidb/store/localstore.(*dbSnapshot).Get(0xc820bb2cc0, 0xc820b8b180, 0x11, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/store/localstore/snapshot.go:34 +0x85
github.com/pingcap/tidb/kv.(*UnionStore).Get(0xc820984420, 0xc820b8b180, 0x11, 0x20, 0x0, 0x0, 0x0, 0x19b0028, 0xc82000b320)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/kv/union_store.go:91 +0x11c
github.com/pingcap/tidb/store/localstore.(*dbTxn).Get(0xc820984420, 0xc820b8b180, 0x11, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/store/localstore/txn.go:110 +0x34a
github.com/pingcap/tidb/table/tables.(*Table).RowWithCols(0xc8209e0360, 0x1b061f0, 0xc8206a71a0, 0x3ef, 0xc8209e4800, 0x8, 0x8, 0x0, 0x0, 0x0, ...)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/table/tables/tables.go:416 +0x23d
github.com/pingcap/tidb/table/tables.(*Table).Row(0xc8209e0360, 0x1b061f0, 0xc8206a71a0, 0x3ef, 0x0, 0x0, 0x0, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/table/tables/tables.go:434 +0xce
github.com/pingcap/tidb/plan/plans.(*TableDefaultPlan).Do(0xc820b28390, 0x1b061f0, 0xc8206a71a0, 0xc820b28570, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/plan/plans/from.go:287 +0x3d1
github.com/pingcap/tidb/plan/plans.(*JoinPlan).Do(0xc8209842a0, 0x1b061f0, 0xc8206a71a0, 0xc820b28570, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/plan/plans/join.go:144 +0x6e
github.com/pingcap/tidb/plan/plans.(*JoinPlan).doCrossJoin(0xc820984240, 0x1b061f0, 0xc8206a71a0, 0xc8206956d0, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/plan/plans/join.go:186 +0xd7
github.com/pingcap/tidb/plan/plans.(*JoinPlan).Do(0xc820984240, 0x1b061f0, 0xc8206a71a0, 0xc8206956d0, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/plan/plans/join.go:155 +0x24b
github.com/pingcap/tidb/plan/plans.(*FilterDefaultPlan).Do(0xc820a7f2c0, 0x1b061f0, 0xc8206a71a0, 0xc820b28510, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/plan/plans/where.go:76 +0x1ad
github.com/pingcap/tidb/plan/plans.(*SelectLockPlan).Do(0xc820a7f300, 0x1b061f0, 0xc8206a71a0, 0xc820695680, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/plan/plans/lock.go:63 +0xd7
github.com/pingcap/tidb/plan/plans.(*SelectFieldsDefaultPlan).Do(0xc820a7f6c0, 0x1b061f0, 0xc8206a71a0, 0xc820a7f7a0, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/plan/plans/fields.go:76 +0x1ad
github.com/pingcap/tidb/plan/plans.(*SelectFinalPlan).Do(0xc820a7f700, 0x1b061f0, 0xc8206a71a0, 0xc820bb2c90, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/plan/plans/final.go:59 +0xc4
github.com/pingcap/tidb/rset/rsets.Recordset.Do(0x1b061f0, 0xc8206a71a0, 0x1b06ce8, 0xc820a7f700, 0xc820bb2c80, 0x0, 0x0)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/rset/rsets/rsets.go:46 +0x97
github.com/pingcap/tidb/rset/rsets.(*Recordset).Do(0xc820a7f720, 0xc820bb2c80, 0x0, 0x0)
    <autogenerated>:6 +0xac
github.com/pingcap/tidb.newdriverRows.func1(0xc820a7f740)
    /Users/lunny/gopath/src/github.com/pingcap/tidb/driver.go:368 +0xa9
created by github.com/pingcap/tidb.newdriverRows
    /Users/lunny/gopath/src/github.com/pingcap/tidb/driver.go:387 +0xeb

@shenli
Copy link
Member

shenli commented Sep 8, 2015

@lunny I find a potential bug in go-xorm/tests
When call testDelete multiple times, the environment is not clean. There is not drop table statement before or after the test.
https://github.com/go-xorm/tests/blob/master/testDelete.go#L49

I find an error when run test. Adding "engine.DropTables(&Deleted{})" before "engine.CreateTables(&Deleted{})" will fix it.

Please take a look. Thanks!

@lunny
Copy link
Author

lunny commented Sep 8, 2015

I have fixed this on go-xorm/tests@811ef5c. But there are still panics. @shenli

siddontang added a commit that referenced this issue Sep 9, 2015
@siddontang
Copy link
Member

Hi @lunny

We create a branch to fix the panic, could you help us to check with it?

The branch is https://github.com/pingcap/tidb/tree/siddontang/fix-driver-panic

@lunny
Copy link
Author

lunny commented Sep 9, 2015

I have run go test with the branch siddontang/fix-driver-panic, and I get the only one problem below:

--- FAIL: TestTidbWithCache (7.31s)
    testForUpdate.go:99: read lock failed
FAIL
exit status 1
FAIL    github.com/go-xorm/tidb 14.962s

This is occupied on the testForUpdate, may be tidb don't support select .. for update yet?

@siddontang
Copy link
Member

@shenli is fixing it.
Btw, there seems no panic?

@lunny
Copy link
Author

lunny commented Sep 9, 2015

Yes. no panic this time. It works well. If @shenli fix that. All the xorm tests will be passed.

@ngaut
Copy link
Member

ngaut commented Sep 9, 2015

TiDB support "select for update". But there are tiny difference between TiDB and MySQL.
Because TiDB use Optimistic concurrency control.

There are some details in Wikipedia:
Optimistic concurrency control (OCC) is a concurrency control method applied to transactional systems such as relational database management systems and software transactional memory. OCC assumes that multiple transactions can frequently complete without interfering with each other. While running, transactions use data resources without acquiring locks on those resources. Before committing, each transaction verifies that no other transaction has modified the data it has read. If the check reveals conflicting modifications, the committing transaction rolls back and can be restarted.[1] Optimistic concurrency control was first proposed by H.T. Kung.[2]

OCC is generally used in environments with low data contention. When conflicts are rare, transactions can complete without the expense of managing locks and without having transactions wait for other transactions' locks to clear, leading to higher throughput than other concurrency control methods. However, if contention for data resources is frequent, the cost of repeatedly restarting transactions hurts performance significantly; it is commonly thought that other concurrency control methods have better performance under these conditions. However, locking-based ("pessimistic") methods also can deliver poor performance because locking can drastically limit effective concurrency even when deadlocks are avoided.

Contents [hide]
1 OCC phases
2 Web usage
2.1 Examples
3 See also
4 References
5 External links
OCC phases[edit]

This section does not cite any references or sources. Please help improve this section by adding citations to reliable sources. Unsourced material may be challenged and removed. (August 2010)
More specifically, OCC transactions involve these phases:

Begin: Record a timestamp marking the transaction's beginning.
Modify: Read database values, and tentatively write changes.
Validate: Check whether other transactions have modified data that this transaction has used (read or written). This includes transactions that completed after this transaction's start time, and optionally, transactions that are still active at validation time.
Commit/Rollback: If there is no conflict, make all changes take effect. If there is a conflict, resolve it, typically by aborting the transaction, although other resolution schemes are possible. Care must be taken to avoid a TOCTTOU bug, particularly if this phase and the previous one are not performed as a single atomic operation.

@ngaut
Copy link
Member

ngaut commented Sep 9, 2015

@lunny User may retry transaction when commit "select for update" failed.

@lunny
Copy link
Author

lunny commented Sep 9, 2015

@ngaut OK. Then we can ignore the testForUpdate().

@lunny
Copy link
Author

lunny commented Sep 9, 2015

go-xorm/tests@999772a, I think maybe you can merge branch siddontang/fix-driver-panic.

@lunny lunny closed this as completed Sep 9, 2015
YuJuncen pushed a commit to YuJuncen/tidb that referenced this issue Apr 23, 2021
* mydump/reader: ensure we can't seek beyond EOF

* *: enable `make test` and ensure all test cases can be compiled

* vendor: update vendor

In glide we removed the -s and -u flags since they are on by default, and
removed --skip-test so that github.com/pingcap/check can be vendored.

* makefile: define every test as integration test until TOOL-308 is fixed
YuJuncen pushed a commit to YuJuncen/tidb that referenced this issue Apr 23, 2021
BR closes domain before shutdown, so that it does not affect
TiDB DDL workers.

Signed-off-by: Neil Shen <[email protected]>
okJiang pushed a commit to okJiang/tidb that referenced this issue Oct 19, 2021
* add noData\noSchemas cli parameters

* add noData\noSchemas cli parameters

* add noData\noSchemas cli parameters
Defined2014 added a commit to Defined2014/tidb that referenced this issue Apr 11, 2022
iosmanthus pushed a commit to iosmanthus/tidb that referenced this issue Oct 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

6 participants