CONCURRENCY AND SCHEDULING Flashcards
What is concurrency?
Multiple transactions are allowed to run simultaneously in the system
What are the advantages of using concurrency?
Increased processor and disk utilization: leading to better transaction throughput. One transaction can be using the CPU while another transaction reads from the disk.
Reduced average response time for transactions: Short transactions need not to wait for long ones
What are the expectations of concurrency control?
Isolation is maintained: Users must be able to execute each transactions as if they were the only user.
DBMS handles the details of interleaving various TXNs
Consistency is maintained: Transactions must leave the DB in a consistent state
DBMS handles the details of enforcing integrity constraints
What problems can be caused by concurrency?
Dirty Read/ Reading Uncommitted data
Lost update problem
Inconsistent analysis problem
Describe dirty read
Occurs because of a WriteRead conflict
It occurs when one transaction is allowed to see the intermediate results of another transaction before it is committed.
*See doc for pic
What is dirty data?
Data written by an uncommitted transaction due to system failure or rollback
Describe the lost update problem
Occurs because of a Write Write conflict
An apparently successfully completed update operation by one user can be overridden by another user.
*See notes for pic
Describe the inconsistent analysis problem
Occurs when a transaction reads several values form the database but a second transaction updates some of them during the execution of the first.
*See notes for pic
What is a schedule?
Sequences that indicate the order in which instructions of concurrent transactions are executed
What is a serial schedule?
A schedule where one transaction executes fully before the next transaction starts.
A serial schedule is one that does not interleave the actions of different transactions
What is a non-serial schedule?
A schedule where two transactions are interleaved
What situations may lead to the interleaving of transactions?
Individual Transactions might be slow- don’t want to block other users during execution
Disk access may be slow- let some transactions use CPUs while others accessing disk!
What is the prerequisite for interleaving transactions?
DBMS must pick an interleaving or schedule such that isolation and consistency are maintained
Must be as if the transactions had executed serially!
When is a schedule said to be not serializable?
An interleaved schedule is said to be not serializable if it gives different results from any serial schedule
What are equivalent schedules?
A and B are equivalent schedules if, for any database state, the effect on DB of executing A is identical to the effect of executing B
What is a serializable schedule?
A serializable schedule is a schedule that is equivalent to some serial execution of the transactions
What is concurrency control?
The general process of ensuring that transactions preserve consistency, when executing simultaneously.
Interactions among concurrently executing transactions, can cause the database to become inconsistent, even when there is no system failure.
Thus, the timings of different transactions need to be regulated in some manner.
What are the two main approaches to concurrency control?
Pessimistic approach: Locks
Optimistic Approach: Timestamps, multi-version, validation
What is concurrency control
Concurrency control: The process of managing simultaneous operations on the database without having them interfere with one another.