mysql 更新唯一主键列 被堵塞

mysql> select @@tx_isolation;   
+-----------------+
| @@tx_isolation  |
+-----------------+
| REPEATABLE-READ |
+-----------------+
1 row in set (0.00 sec)

Session 196:

mysql> show create table mail;
+-------
| mail  | CREATE TABLE `mail` (
  `mailid` bigint(20) NOT NULL AUTO_INCREMENT,
  `receiverid` int(10) unsigned NOT NULL,
  `senderid` int(10) unsigned NOT NULL,
  PRIMARY KEY (`mailid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |


mysql> insert into mail values(1,2222,3333);
Query OK, 1 row affected (0.00 sec)

mysql> insert into mail values(2,333,3333);
Query OK, 1 row affected (0.00 sec)

mysql> commit;
Query OK, 0 rows affected (0.00 sec)

mysql> start transaction;
Query OK, 0 rows affected (0.00 sec)

mysql> insert into mail values(3,333,3333);
Query OK, 1 row affected (0.00 sec)

mysql> select connection_id(); 
+-----------------+
| connection_id() |
+-----------------+
|             196 |
+-----------------+
1 row in set (0.02 sec)



Session 197:


mysql> update mail set receiverid=193719371 where mailid=3;
ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
mysql> update mail set receiverid=193719371 where mailid=3;
ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
mysql> select connection_id(); 
+-----------------+
| connection_id() |
+-----------------+
|             197 |
+-----------------+
1 row in set (0.00 sec)

mysql> update mail set receiverid=193719371 where mailid=3;




389253799,197,update mail set receiverid=193719371 where mailid=3,389253798,196,
 mysql[192.168.11.187]   blocking_thread[196] current_query[]  blocking waiting_thread[197]'s update mail set receiverid=193719371 where mailid=3
,,,,,
,,,,,
,,,,,
,,,,,
,,,,,
,,,,,

posted @   czcb  阅读(268)  评论(0编辑  收藏  举报
编辑推荐:
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 字符编码:从基础到乱码解决
点击右上角即可分享
微信分享提示