pub enum IsolationLevel {
Default,
ReadUncommitted,
ReadCommitted,
RepeatableRead,
Snapshot,
Serializable,
Linearizable,
}
Expand description
Isolation level value for key OptionConnection::IsolationLevel.
Variants§
Default
Use database or driver default isolation level.
ReadUncommitted
The lowest isolation level. Dirty reads are allowed, so one transaction may see not-yet-committed changes made by others.
ReadCommitted
Lock-based concurrency control keeps write locks until the end of the transaction, but read locks are released as soon as a SELECT is performed. Non-repeatable reads can occur in this isolation level.
More simply put, ReadCommitted
is an isolation level that guarantees
that any data read is committed at the moment it is read. It simply
restricts the reader from seeing any intermediate, uncommitted,
‘dirty’ reads. It makes no promise whatsoever that if the transaction
re-issues the read, it will find the same data; data is free to change
after it is read.
RepeatableRead
Lock-based concurrency control keeps read AND write locks (acquired on selection data) until the end of the transaction.
However, range-locks are not managed, so phantom reads can occur. Write skew is possible at this isolation level in some systems.
Snapshot
This isolation guarantees that all reads in the transaction will see a consistent snapshot of the database and the transaction should only successfully commit if no updates conflict with any concurrent updates made since that snapshot.
Serializable
Serializability requires read and write locks to be released only at the end of the transaction. This includes acquiring range-locks when a select query uses a ranged WHERE clause to avoid phantom reads.
Linearizable
The central distinction between serializability and linearizability is that serializability is a global property; a property of an entire history of operations and transactions. Linearizability is a local property; a property of a single operation/transaction.
Linearizability can be viewed as a special case of strict serializability where transactions are restricted to consist of a single operation applied to a single object.