1
yangqi 2016-07-13 22:13:29 +08:00 1
"WRITE locks normally have higher priority than READ locks to ensure that updates are processed as soon as possible. This means that if one session obtains a READ lock and then another session requests a WRITE lock, subsequent READ lock requests wait until the session that requested the WRITE lock has obtained the lock and released it.
LOCK TABLES acquires locks as follows: 1.Sort all tables to be locked in an internally defined order. From the user standpoint, this order is undefined. 2.If a table is to be locked with a read and a write lock, put the write lock request before the read lock request. 3.Lock one table at a time until the session gets all locks." |
2
Rosicky OP 手动加锁和自动加锁有什么区别?
|
3
Rosicky OP 贴下另一组测试,顺序运行
1 、 A 运行: mysql> lock table tx read; Query OK, 0 rows affected (9 min 37.73 sec) 2 、 B 运行: mysql> lock table tx read; 这里在等待 3 、 C 运行: mysql> lock table tx write; 这里在等待 4 、 A 运行: mysql> unlock tables; Query OK, 0 rows affected (0.00 sec) 此时看控制台 C 已获得锁, B 等待。这个结果就和文档一样 |