Isolation of Transaction Properties

Isolation of Transaction Attributes


Contents


Concurrency Control
Isolation processing and ensuring the correctness of related operations are the basic mechanisms that must be covered in concurrency control of database management systems. This mechanism is used extensively in databases and storage engines to ensure the correct execution of concurrent transactions.
Two-phase locking is the most commonly used transaction concurrency control method in database management systems. Used to provide serializable and recoverable properties for correctness. In order to access a database object, a transaction must first acquire a lock on the object. This depends on the type of access operation (such as reading or writing objects) and the type of lock to be acquired. If the lock is occupied by another transaction, the acquisition of the lock may be blocked or may need to be delayed for a period of time before acquiring.

Differences between various locks in the database
Due to the relationship between various data, many data use different or even confusing names when describing locks. Such as shared locks, exclusive locks, read locks, write locks, Share locks, Exclusive locks, S locks, X locks, explicit locks, and implicit locks.
In fact, there are only two kinds of locks here, the more standardized names are read locks and write locks.
Shared locks are actually read locks, and exclusive locks are actually write locks; Share locks are actually read locks, and Exclusive locks are actually write locks; S locks are actually read locks, and X locks are actually write locks.
The read lock is a shared lock. During the lock period, other transactions are allowed to add read locks to the data, but no write locks are allowed, that is, other transactions are allowed to read but not write.
Write locks are exclusive, also known as exclusive locks. During the lock period, other transactions cannot add read locks or write locks to data, that is, other transactions read or write.
In addition, regarding explicit locks and implicit locks, implicit locks refer to the fact that locks are implicitly (automatically) locked during data operations (such as addition, deletion, modification, and search), but for different operations, the types of locks are different. . Explicit locks mean that we can explicitly set locks, such as write locks that specify exclusive operations that can be displayed in query operations. Such as:
select … from … where … for update


Isolation Levels
Isolation levels are defined in the SQL standard (http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt), chapter 4.28 SQL-transactions.


Serializable
This is the highest isolation level.
In a database management system implementation of lock-based concurrency control, serializability requires acquiring read and write locks on selected data and releasing read and write locks at the end of a transaction. Range locks must also be acquired when a select query uses a WHERE condition that represents a query for a range of data.
If you are using non-lock based concurrency control, you do not need to acquire locks; however, if the system detects a write conflict in multiple concurrent transactions, only one is allowed to commit.

Repeatable read

Committed read

Uncommitted read

Read phenomenon
Dirty read

Non- repeatable read

Phantom

read Relationship between isolation level and read phenomenon Isolation level

Dirty read Unrepeatable read Phantom
read Uncommitted read y y y
Commit read n y y
Repeatable read n n y
Serializable n n n


and lock-in period

Isolation Level Write Operation Read Operation Range Operation (where ...)
Uncommitted Read S S S
Committed Read C S S
Repeatable Read C C S
Serializable C C C



1, https://en.wikipedia.org/wiki/Isolation_(database_systems)
2, http:/ /www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt
3. BNF Grammar for ISO/IEC 9075:1992 - Database Language SQL (SQL-92), http://savage.net.au/ SQL/sql-92.bnf.html
4.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326618461&siteId=291194637