MySql transaction isolation level and lock briefly describes the transaction feature ACID, namely atomicity, consistency, isolation, and durability. Atomicity ensures that a transaction is a minimum unit, and internal non-segmentation consistency ensures that each operation thread in the transaction cannot be submitted separately. If successful, the transaction is committed together, if the transaction fails, the transaction rollback isolation ensures that the data view between different transactions is consistent.
MySql transaction isolation level and lock briefly describes the transaction feature ACID, namely atomicity, consistency, isolation, and durability. Atomicity ensures that a transaction is a minimum unit, and internal non-segmentation consistency ensures that each operation thread in the transaction cannot be submitted separately. If successful, the transaction is committed together, if the transaction fails, the transaction rollback isolation ensures that the data view between different transactions is consistent.
MySql transaction isolation level and lock description
The characteristic ACID of a transaction, that is, atomicity, consistency, isolation, and durability.
Atomicity ensures that a transaction is a minimum unit, which is inseparable from each other.
Consistency ensures that each operation thread in the transaction cannot be submitted separately. If the operation is successful, the transaction is committed together. If the operation fails, the transaction is rolled back.
Isolation ensures that the data views seen by different transactions are isolated from each other (isolation level can be set)
Durability ensures that the data is permanently saved after the transaction is committed.
?
There are four database isolation levels-- High-performance mysql
Another case is Lost Update. Transaction A and transaction B Update data d1. After commit, transaction A rolls back the data and A sees that the modification does not take effect, lost. Read uncommitted can avoid this situation.
?
MySql lock description
The types can be divided into shared lock and exclusive lock, read lock, and write lock ).
Table sharding locks and row locks are divided according to the granularity. Table locks are implemented by the database server, and row locks are implemented by the storage engine.
?
Shared lock
The granularity of the shared locks is rows or tuples (multiple rows ). After a transaction acquires a shared lock, it can perform read operations on the data within the lock range .?
Exclusive lock
The granularity of the exclusive lock is the same as that of the shared lock. After a transaction obtains the exclusive lock, it can perform write operations on the data within the lock range.
?
Assume that there are two transactions t1 and t2
If transaction t1 acquires the shared lock of A tuples, transaction t2 can also immediately obtain the shared lock of the tuples, but cannot immediately obtain the exclusive lock of the tuples (after t1 releases the shared lock ).
If transaction t1 acquires the exclusive lock of A tuples, transaction t2 cannot immediately obtain the exclusive lock of the tuples or immediately obtain the exclusive lock of the tuples (after t1 releases the exclusive lock ).