Data concurrency
To improve transaction processing capabilities, OceanBase Database allows multiple transactions to access and modify the same data in a concurrent manner. Semantics must be defined for such data concurrency.
Data consistency
OceanBase Database generates a new version for each update to prevent mutual exclusion between reads and writes. This process is called multi-version concurrency control (MVCC). In different versions of transactions, semantics must be defined for multiple versions of data to ensure a consistent database status, which refers to a consistent snapshot of data.
Note
Data consistency is not equivalent to consistency (C) in the atomicity, consistency, isolation, and durability (ACID) properties.
Concurrency control
The preceding two types of semantics are called concurrency control models, which are equivalent to isolation (I) in the ACID properties.
The simplest concurrency control method is serial execution. In serial execution, a process will not trigger an operation until the previous process completes its operation (receives a response). However, this method does not meet the requirement of high concurrency. Therefore, scholars proposed a serializable method. This method can be used to perform multiple operations of a transaction in parallel (not in series) and achieve the same results as serial execution.
Conflict serializability can be implemented by using the following mechanisms: two-phase locking and optimistic locking. Two-phase locking uses locks to limit conflicting modifications of transactions and supports deadlock detection to roll back circular transactions and prevent loops. Optimistic locking rolls back all possible abnormal transactions in the detection phase during a commit to prevent exceptions.
However, the serializable isolation level implemented in the preceding two mechanisms greatly affects performance. Therefore, specific acceptable circularization conditions are often allowed to expose exceptions and improve the performance and scalability of transactions. The snapshot read and read committed isolation levels are common concurrency control methods that allow exceptions. OceanBase Database supports these methods. The balance between performance and semantic usability is essential to designing transaction isolation levels.