Mysql行锁
现象是会话2的进程不能提交,会被1阻塞住,只有会话1的sql commit,2才能提交。事实上这2个sql会互相阻塞,即会话1不提交的情况,2没法提交,会话2不提交的情况,会话1也不能提交。
3)show innodb status \G;
LOCK WAIT 2 lock struct(s), heap size 320, 1 row lock(s)
MySQL thread id 81317, query id 114219375 localhost dragoon_test update
insert into test values(7)
------- TRX HAS BEEN WAITING 19 SEC FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 2836 page no 3 n bits 80 index `GEN_CLUST_INDEX` of table `test`.`test` trx id 0 809608184 lock_mode X insert intention waiting
4)在id上增加索引
Create index idx_idon test (id);
会话1:
Set autocommit=0;
insert into test1selectidfrom test where id
页:
[1]