Concurrency control Flashcards
What is a transaction?
A set of several operations constituting a logical task unit, converting a consistent state of the database to another consistent state.
What are the ACID properties of a transaction?
- Atomicity
- Consistency
- Isolation
- Durability
Define Atomicity in the context of transactions.
All data should be successfully entered or failed in one transaction.
Define Consistency in the context of transactions.
The transaction result should always be the same expected value.
Define Isolation in transaction properties.
Another transaction should not intervene until commit or rollback is issued.
Define Durability in the context of transactions.
The persistence of a successful transaction should be guaranteed.
What is a transaction commit operation?
An operation that completes a transaction after permanently reflecting the results of all SQL statements in the database.
What is a transaction rollback operation?
An operation that restores all data values modified by a transaction to the state prior to execution when the transaction cannot continue.
What is the implementation of transaction concurrency?
Simultaneous execution of transactions to increase throughput and reduce latency.
What is a serializable schedule?
A schedule where transactions executed simultaneously yield the same result as sequential execution.
Define concurrency control.
A function that enables the successful execution of several transactions simultaneously in a database system.
What are the purposes of concurrency control?
- Create serializable schedules
- Guarantee maximum sharing
- Ensure data integrity and consistency
What is a lost update?
Occurs when transactions update the same data simultaneously, leading to overwriting of updates.
What is a dirty read?
Occurs when other transactions refer to the intermediate execution result of a transaction.
What is inconsistency in databases?
A database remains inconsistent when two transactions are executed simultaneously.
What is a cascading rollback?
Occurs when a specific transaction cancels processing, affecting other transactions sharing data.
What is an unrepeatable read?
When a transaction executes the same query twice, resulting in different outcomes due to modifications by other transactions.
Name four concurrency control techniques.
- Lock-based technique
- Timestamp-based technique
- Multi-version technique
- Verification (optimistic) based technique
What is the lock-based technique?
A mechanism where a transaction cannot read or write data until it acquires an appropriate lock.
What is the timestamp-based technique?
An algorithm using system time or logical counter as a timestamp to serialize concurrent transactions.
What is multiversion concurrency control (MVCC)?
A technique that creates duplicate copies of records allowing safe reading and updating of data simultaneously.
How does MVCC work?
- Every database record has a version number
- Concurrent reads happen against the highest version
- Write operations operate on a copy of the record
- Version id increments after a successful write
What is the difference between MVCC and locking?
MVCC does not lock records; it creates new versions for write operations, allowing concurrent reads.
What are the drawbacks of MVCC?
- Difficult to implement concurrent update control methods
- Database size may increase due to multiple record versions