Concurrency control
|
In computer science -- more specifically, in the field of databases -- concurrency control is a method used to ensure that database transactions are executed in a safe manner (i.e., without data loss). Concurrency control is especially applicable to database management systems, which must ensure that transactions are executed safely and that they follow the ACID rules, as described in the following section. The DBMS must be able to ensure that only serializable, recoverable schedules are allowed, and that no actions of committed transactions are lost while undoing aborted transactions.
Transaction ACID rules
- Atomicity - Either all or no operations are completed. (Undo)
- Consistency - All transactions must leave the database in consistent state.
- Isolation - Transactions cannot interfere with each other.
- Durability - Successful transactions must persist through crashes. (Redo)
Concurrency control mechanism
The main categories of concurrency control mechanisms are:
- Pessimist - The concurrent executions of transactions are synchronized early in their execution life cycle.
- Optimistic - Delay the synchronization for transactions until their termination.
There are several methods for concurrency control, the majority of which uses Strict 2PL locking:
- Strict two-phase locking
- Non-strict two-phase locking
- Conservative two-phase locking
- Index locking
- Multiple granularity locking
Locks are bookkeeping objects associated with a database object.
There are also Non-lock concurrency control methods. All the currently implemented lock-based and almost all the implemented non-lock based concurrency controls will guarantee that the resultant schedule is conflict serializable; however, there are many academic texts encouraging view serializable schedules for environments where gains due to improvement in concurrency outstrip overheads in generating schedule plans.