奇怪的区间锁问题
来源:互联网 发布:java 常量初始化 编辑:程序博客网 时间:2024/06/05 23:39
Session 1:mysql> select * from t1;+-----+------+------+| sn | id | info |+-----+------+------+| 235 | 1 | a1 || 236 | 2 | a2 || 237 | 3 | a3 || 238 | 4 | a4 || 239 | 5 | a5 || 240 | 6 | a6 || 241 | 7 | a7 || 242 | 8 | a8 || 243 | 9 | a9 || 244 | 10 | a10 || 245 | 15 | a15 |+-----+------+------+11 rows in set (0.00 sec)mysql> show index from t1;+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+| t1 | 0 | PRIMARY | 1 | sn | A | 11 | NULL | NULL | | BTREE | | || t1 | 1 | t1_idx1 | 1 | id | A | 11 | NULL | NULL | YES | BTREE | | |+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+2 rows in set (0.00 sec)Session 2:Database changedmysql> update t1 set id=400 where id=4;Query OK, 1 row affected (0.00 sec)Rows matched: 1 Changed: 1 Warnings: 0mysql> rollback;Query OK, 0 rows affected (0.01 sec)mysql> update t1 set id=500 where id=5;ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transactionmysql> update t1 set id=600 where id=6;ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transactionmysql> update t1 set id=700 where id=7;ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transactionmysql> update t1 set id=800 where id=8;ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transactionmysql> update t1 set id=900 where id=9;Query OK, 1 row affected (0.00 sec)Rows matched: 1 Changed: 1 Warnings: 0/******把t1_idx1 换成unique index 继续测试:Session 1:mysql> create unique index t1_idx1 on t1(id);Query OK, 0 rows affected (0.04 sec)Records: 0 Duplicates: 0 Warnings: 0mysql> mysql> mysql> show index from t1;+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+| t1 | 0 | PRIMARY | 1 | sn | A | 11 | NULL | NULL | | BTREE | | || t1 | 0 | t1_idx1 | 1 | id | A | 11 | NULL | NULL | YES | BTREE | | |+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+2 rows in set (0.00 sec)mysql> select * from t1 where id BETWEEN 5 and 7 for update;+-----+------+------+| sn | id | info |+-----+------+------+| 239 | 5 | a5 || 240 | 6 | a6 || 241 | 7 | a7 |+-----+------+------+3 rows in set (0.00 sec)Session 2:mysql> update t1 set id=400 where id=4;Query OK, 1 row affected (0.00 sec)Rows matched: 1 Changed: 1 Warnings: 0mysql> rollback;Query OK, 0 rows affected (0.01 sec)mysql> update t1 set id=500 where id=5;ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transactionmysql> update t1 set id=600 where id=6;ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transactionmysql> update t1 set id=700 where id=7;ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transactionmysql> update t1 set id=800 where id=8;ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transactionmysql> update t1 set id=900 where id=9;Query OK, 1 row affected (0.00 sec)Rows matched: 1 Changed: 1 Warnings: 0创建唯一锁 仍旧锁住了5,6,7,8 4条记录
0 0
- 奇怪的区间锁问题
- #LightOJ 1422 Halloween奇怪的区间dp
- 奇怪的malloc问题!
- 奇怪的编译问题
- 奇怪的问题。
- 又一奇怪的问题?
- 一个奇怪的问题
- 奇怪的JNI问题
- 奇怪的问题
- 奇怪的问题
- IMPLEMENT_DYNCREATE的奇怪问题
- DotMSN的奇怪问题
- 一些奇怪的问题
- JSF的奇怪问题
- DevCpp的奇怪问题
- 奇怪的问题!
- 奇怪的问题
- 一个奇怪的问题
- 第十一周项目一点圆圆柱类族的设计1
- Python实现爬取知乎神回复简单爬虫代码分享
- java并发编程(十八)--深入Java内存模型—内存操作规则总结
- PAT乙级—1011. A+B和C (15)-native
- Python使用Scrapy爬取妹子图
- 奇怪的区间锁问题
- Linux查看历史命令,并查询操作时间
- 100个常用的Linux命令
- highcharts 开发笔记
- 最常用的 Eclipse 快捷键总结
- python实现爬取千万淘宝商品的方法
- java并发编程(十九)--并发新特性—Executor框架与线程池
- 地图瓦片相关学习总结
- 数组声明(基础)