标签:超时 innodb mysql锁 list 场景 code mysql ESS 定义
LOCK TABLE my_tabl_name READ;
LOCK TABLE my_table_name WRITe;
show processlist; --如果有SUPER权限,可以看到所有线程。否则,只能看到自己的线程
kill id; --id是processlist中锁进程id
UNLOCK TABLES;
show OPEN TABLES where In_use > 0;
select …… for share;
select …… lock in share mode;
--仍能使用select …… for update;
# Session 1:
mysql> CREATE TABLE t (i INT, PRIMARY KEY (i)) ENGINE = InnoDB;
mysql> INSERT INTO t (i) VALUES(1),(2),(3);
mysql> START TRANSACTION;
mysql> SELECT * FROM t WHERE i = 2 FOR UPDATE;
+---+
| i |
+---+
| 2 |
+---+
# Session 2:
mysql> START TRANSACTION;
mysql> SELECT * FROM t WHERE i = 2 FOR UPDATE NOWAIT;
ERROR 3572 (HY000): Do not wait for lock.
# Session 3:
mysql> START TRANSACTION;
mysql> SELECT * FROM t FOR UPDATE SKIP LOCKED;
+---+
| i |
+---+
| 1 |
| 3 |
+---+
标签:超时 innodb mysql锁 list 场景 code mysql ESS 定义
原文地址:https://www.cnblogs.com/holm/p/12841319.html