14 rows in set (0.01 sec)
查询会话session 1,session 2的连接ID
session 1:
MySQL> status;
--------------
mysql Ver 12.22 Distrib 4.0.24, for pc-solaris2.10 (i386)
Connection id: 15
session 2:
mysql> status;
--------------
mysql Ver 12.22 Distrib 4.0.24, for pc-solaris2.10 (i386)
Connection id: 13
在上面的session 1尚没有提交的时候,可以执行下列命令,查看一些事务阻塞信息
mysql> show innodb status\G;
------------
TRANSACTIONS
------------
Trx id counter 0 3852351
Purge done for trx's n:o < 0 3852350 undo n:o < 0 0
History list length 11
Total number of lock structs in row lock hash table 7
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 0 0, not started, OS thread id 15
MySQL thread id 18, query id 2071119 localhost root
show innodb status
---TRANSACTION 0 3852350, ACTIVE 6 sec, OS thread id 14 starting index read
mysql tables in use 1, locked 1
LOCK WAIT 2 lock struct(s), heap size 320
MySQL thread id 13, query id 2071118 localhost test Updating --这里可以看到等待者
update t1 set email='abc' where id=0 --这里可以看到等待者正在执行的SQL
------- TRX HAS BEEN WAITING 6 SEC FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 0 page no 32782 n bits 1056 index `idx_t1_id` of table `dc_test/t1` trx id 0 3852350 lock_mode X waiting
Record lock, heap no 2 PHYSICAL RECORD: n_fields 2; compact format; info bits 0
0: len 4; hex 80000000; asc ;; 1: len 6; hex 00000196fe5d; asc ];;
------------------
---TRANSACTION 0 3852348, ACTIVE 391 sec, OS thread id 12
7 lock struct(s), heap size 1024, undo log entries 4
MySQL thread id 15, query id 2071117 localhost test
