【知识库】--mysql Shared and Exclusive Locks共享锁和排它锁(195)

xiaoxiao2021-02-28  80

S X 锁 可以理解为 类似java中的读写锁 InnoDB implements standard row-level locking where there are two types of locks, shared (S) locks and exclusive (X) locks. A shared (S) lock permits the transaction that holds the lock to read a row. An exclusive (X) lock permits the transaction that holds the lock to update or delete a row. If transaction T1 holds a shared (S) lock on row r, then requests from some distinct transaction T2 for a lock on row r are handled as follows: A request by T2 for an S lock can be granted immediately. As a result, both T1 and T2 hold an S lock on r. A request by T2 for an X lock cannot be granted immediately. If a transaction T1 holds an exclusive (X) lock on row r, a request from some distinct transaction T2 for a lock of either type on rcannot be granted immediately. Instead, transaction T2 has to wait for transaction T1 to release its lock on row r.
转载请注明原文地址: https://www.6miu.com/read-47877.html

最新回复(0)