- tidb 3.0.2
mysql> select @@autocommit;
+--------------+
| @@autocommit |
+--------------+
| 1 |
+--------------+
1 row in set (0.01 sec)
mysql> select * from gold_order where id = '978385712064563224' for update;
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql> select * from gold_order where id = '978385712064563224'G
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 46966
Current database: uu
*************************** 1. row ***************************
id: 978385712064563224
mac: 00-FF-9F-71-D2-B0
uid: 15858140340
item_num: 2086057
unit_price: 0.0172
money: 1000
count: 581
add_time: 2019-10-16 14:14:16
pay_time: NULL
notify_time: NULL
pay_type: NULL
status: 2
pay_order_id: NULL
src_ip: NULL
client_ip: 1699191302
1 row in set (0.03 sec)
如果不开启事务,执行select for update就会报错ERROR 2013 (HY000): Lost connection to MySQL server during query
[2019/10/30 11:24:16.438 +08:00] [ERROR] [conn.go:600] [“connection running loop panic”] [conn=3876] [lastCmd=“select * from gold_order where id = ‘978385712064563224’ LIMIT 0, 1 for update”] [err="“invalid memory address or nil pointer dereference”"] [stack="goroutine 463777194 [running]: github.com/pingcap/tidb/server.(*clientConn).Run.func1(0x226a420, 0xc027f2a600, 0xc0364e9ba0) /home/jenkins/workspace/release_tidb_3.0/go/src/github.com/pingcap/tidb/server/conn.go:598 +0xee panic(0x1d9bb00, 0x31bc9b0) /usr/local/go/src/runtime/panic.go:522 +0x1b5 github.com/pingcap/tidb/server.(*clientConn).writeResultset.func1(0x0, 0x227c320, 0xc00e440d70, 0xc019ce5738, 0x226a420, 0xc027f2a600, 0xc0364e9ba0) /home/jenkins/workspace/release_tidb_3.0/go/src/github.com/pingcap/tidb/server/conn.go:1261 +0x59c panic(0x1d9bb00, 0x31bc9b0) /usr/local/go/src/runtime/panic.go:522 +0x1b5 github.com/pingcap/tidb/session.(*TxnState).LockKeys(0xc0166c0970, 0x226a420, 0xc027f2a600, 0x5b86ac522a80001, 0xc00e76a340, 0x1, 0x1, 0x0, 0x0) :1 +0x36 github.com/pingcap/tidb/executor.(*PointGetExecutor).lockKeyIfNeeded(0xc054769680, 0x226a420, 0xc027f2a600, 0xc02a978c20, 0x13, 0x13, 0xd0, 0x0) /home/jenkins/workspace/release_tidb_3.0/go/src/github.com/pingcap/tidb/executor/point_get.go:152 +0x144 github.com/pingcap/tidb/executor.(*PointGetExecutor).Next(0xc054769680, 0x226a420, 0xc027f2a600, 0xc011cae2d0, 0x0, 0x0) /home/jenkins/workspace/release_tidb_3.0/go/src/github.com/pingcap/tidb/executor/point_get.go:132 +0x1cc github.com/pingcap/tidb/executor.Next(0x226a420, 0xc027f2a600, 0x2270ca0, 0xc054769680, 0xc011cae2d0, 0xc011cae2d0, 0x3536950) /home/jenkins/workspace/release_tidb_3.0/go/src/github.com/pingcap/tidb/executor/executor.go:191 +0xbd github.com/pingcap/tidb/executor.(*recordSet).Next(0xc00e440d20, 0x226a420, 0xc027f2a600, 0xc011cae2d0, 0x0, 0x0) /home/jenkins/workspace/release_tidb_3.0/go/src/github.com/pingcap/tidb/executor/adapter.go:109 +0xb0 github.com/pingcap/tidb/server.(*tidbResultSet).Next(0xc00e440d70, 0x226a420, 0xc027f2a600, 0xc011cae2d0, 0x4, 0x400) /home/jenkins/workspace/release_tidb_3.0/go/src/github.com/pingcap/tidb/server/driver_tidb.go:365 +0x51 github.com/pingcap/tidb/server.(*clientConn).writeChunks(0xc0364e9ba0, 0x226a420, 0xc027f2a600, 0x227c320, 0xc00e440d70, 0xc000005700, 0x226a420, 0xc027f2a600) /home/jenkins/workspace/release_tidb_3.0/go/src/github.com/pingcap/tidb/server/conn.go:1308 +0x319 github.com/pingcap/tidb/server.(*clientConn).writeResultset(0xc0364e9ba0, 0x226a420, 0xc027f2a600, 0x227c320, 0xc00e440d70, 0xc000003e00, 0x0, 0x0, 0x0) /home/jenkins/workspace/release_tidb_3.0/go/src/github.com/pingcap/tidb/server/conn.go:1274 +0x1a1 github.com/pingcap/tidb/server.(*clientConn).handleQuery(0xc0364e9ba0, 0x226a420, 0xc027f2a600, 0xc00e442191, 0x4e, 0x0, 0x0) /home/jenkins/workspace/release_tidb_3.0/go/src/github.com/pingcap/tidb/server/conn.go:1191 +0x212 github.com/pingcap/tidb/server.(*clientConn).dispatch(0xc0364e9ba0, 0x226a420, 0xc027f2a600, 0xc00e442191, 0x4f, 0x4f, 0x0, 0x0) /home/jenkins/workspace/release_tidb_3.0/go/src/github.com/pingcap/tidb/server/conn.go:897 +0x5c6 github.com/pingcap/tidb/server.(*clientConn).Run(0xc0364e9ba0, 0x226a420, 0xc027f2a600) /home/jenkins/workspace/release_tidb_3.0/go/src/github.com/pingcap/tidb/server/conn.go:652 +0x258 github.com/pingcap/tidb/server.(*Server).onConn(0xc00028d980, 0xc0364e9ba0) /home/jenkins/workspace/release_tidb_3.0/go/src/github.com/pingcap/tidb/server/server.go:440 +0x481 created by github.com/pingcap/tidb/server.(*Server).Run /home/jenkins/workspace/release_tidb_3.0/go/src/github.com/pingcap/tidb/server/server.go:357 +0x83d "] [stack=“github.com/pingcap/tidb/server.(*clientConn).Run.func1 /home/jenkins/workspace/release_tidb_3.0/go/src/github.com/pingcap/tidb/server/conn.go:600 runtime.gopanic /usr/local/go/src/runtime/panic.go:522 github.com/pingcap/tidb/server.(*clientConn).writeResultset.func1 /home/jenkins/workspace/release_tidb_3.0/go/src/github.com/pingcap/tidb/server/conn.go:1261 runtime.gopanic /usr/local/go/src/runtime/panic.go:522 runtime.panicmem /usr/local/go/src/runtime/panic.go:82 runtime.sigpanic /usr/local/go/src/runtime/signal_unix.go:390 github.com/pingcap/tidb/session.(*TxnState).LockKeys :1 github.com/pingcap/tidb/executor.(*PointGetExecutor).lockKeyIfNeeded /home/jenkins/workspace/release_tidb_3.0/go/src/github.com/pingcap/tidb/executor/point_get.go:152 github.com/pingcap/tidb/executor.(*PointGetExecutor).Next /home/jenkins/workspace/release_tidb_3.0/go/src/github.com/pingcap/tidb/executor/point_get.go:132 github.com/pingcap/tidb/executor.Next /home/jenkins/workspace/release_tidb_3.0/go/src/github.com/pingcap/tidb/executor/executor.go:191 github.com/pingcap/tidb/executor.(*recordSet).Next /home/jenkins/workspace/release_tidb_3.0/go/src/github.com/pingcap/tidb/executor/adapter.go:109 github.com/pingcap/tidb/server.(*tidbResultSet).Next /home/jenkins/workspace/release_tidb_3.0/go/src/github.com/pingcap/tidb/server/driver_tidb.go:365 github.com/pingcap/tidb/server.(*clientConn).writeChunks /home/jenkins/workspace/release_tidb_3.0/go/src/github.com/pingcap/tidb/server/conn.go:1308 github.com/pingcap/tidb/server.(*clientConn).writeResultset /home/jenkins/workspace/release_tidb_3.0/go/src/github.com/pingcap/tidb/server/conn.go:1274 github.com/pingcap/tidb/server.(*clientConn).handleQuery /home/jenkins/workspace/release_tidb_3.0/go/src/github.com/pingcap/tidb/server/conn.go:1191 github.com/pingcap/tidb/server.(*clientConn).dispatch /home/jenkins/workspace/release_tidb_3.0/go/src/github.com/pingcap/tidb/server/conn.go:897 github.com/pingcap/tidb/server.(*clientConn).Run /home/jenkins/workspace/release_tidb_3.0/go/src/github.com/pingcap/tidb/server/conn.go:652 github.com/pingcap/tidb/server.(*Server).onConn /home/jenkins/workspace/release_tidb_3.0/go/src/github.com/pingcap/tidb/server/server.go:440”]