The difference between lock and latch

The difference between lock and latch

Latches are generally called latches (lightweight locks) because they require a very short lock time. If the duration is long, the performance of the application will be very poor. In the InnoDB storage engine, latches are divided into mutex (mutual exclusion lock) and rwlock (read-write lock). Its purpose is to ensure the correctness of concurrent threads operating critical resources, and there is usually no deadlock detection mechanism.

The object of lock is a transaction, and it is used to lock objects in the database, such as tables, pages, and rows. And generally lock objects are released only after transaction commit or rollback (the release time may be different for different transaction isolation levels). In addition, lock, as in most databases, has a deadlock mechanism. The following figure shows the difference between lock and latch:

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_35371323/article/details/110793764
Recommended