Professional Documents
Culture Documents
DBMS Module 5
DBMS Module 5
DBMS Module 5
Assume that two people who go to electronic kiosks at the same time to buy a movie
ticket for the same movie and the same show time.
However, there is only one seat left in for the movie show in that particular theatre.
Without concurrency control in DBMS, it is possible that both moviegoers will end up
purchasing a ticket. However, concurrency control method does not allow this to
happen. Both moviegoers can still access information written in the movie seating
database. But concurrency control only provides a ticket to the buyer who has
completed the transaction process first.
3) Explain the undo and redo operations with recovery techniques that use each.
a. Active Transaction list: All active (uncommitted) transaction ids are entered
in this list.
During recovery, transactions in commit list are redone; transactions in active list are
ignored (because of NO-STEAL rule, none of their writes have been applied to the
database on disk).
Some transactions may be redone twice; this does not create inconsistency because
REDO is “idempotent”, that is, one REDO for an AFIM is equivalent to multiple REDO
for the same AFIM.
Transactions in active list are undone; transactions in committed list are ignored
(because based on FORCE rule, all their changes are already written to the database
on disk).
4) When deadlock and starvation problem occur? Explain how these can be resolved.
Deadlock:
Transition T1 holds a lock on some rows in student table and T2 holds lock on some
rows of Grade table.
But T1 want to update the table held by T2(Grade) and vice versa. (Further explain)
All activity comes to a halt and remains at a standstill forever unless the DBMS
detects the deadlock and abort one of the transactions.
Two schemes that prevent deadlock are called wait-die and wound-wait.
1. Wait-die: In wait-die, an older transaction is allowed to wait for a younger
transaction, whereas a younger transaction requesting an item held by an
older transaction is aborted and restarted.
2. Wound-wait: The wound-wait approach does the opposite: A younger
transaction is allowed to wait for an older one, whereas an older transaction
requesting an item held by a younger transaction preempts the younger
transaction by aborting it.
Starvation:
Another problem that may occur when we use locking is starvation, which occurs
when a transaction cannot proceed for an indefinite period of time while other
transactions in the system continue normally.
This may occur if the waiting scheme for locked items is unfair in that it gives priority
to some transactions over others.
One solution for starvation is to have a fair waiting scheme, such as using a first-
come-first-served queue; transactions are enabled to lock an item in the order in
which they originally requested the lock.
The wait-die and wound-wait schemes discussed previously avoid starvation,
because they restart a transaction that has been aborted with its same original
timestamp, so the possibility that the same transaction is aborted repeatedly.
5) Write and explain the Two-phase locking protocols for concurrency control.
T1 T2
1 Read-Lock(A)
2 Read-Lock(A)
3 Write-Lock(B)
4 ……. …….
5 Unlock(A)
6 Write-lock(C)
7 Unlock(A)
8 Unlock(A)
9 Unlock(C)
10 ……. …….
In transaction T1:
1. Growing phase is from step 1-3.
2. Shrinking phase is from step 5-7.
3. Lock point at 3.
In transaction T2:
1. Growing phase is from step 2-6.
2. Shrinking phase is from step 8-9.
3. Lock point at 6.
Here lock point is the point a which growing phase ends.
The locking protocol, by enforcing two-phase locking rules, also enforces
serializability.
Some drawbacks of 2-PL are
1. Cascading rollback is possible under 2-PL.
2. Deadlock and Starvation are possible.
ARIES uses a steal / no-force approach for writing and it is based on three Concepts.
1. write-ahead logging
2. Repeating history during redo
3. logging changes during undo
The ARIES recovery procedure consists of 3 main steps.
1. Analysis.
2. REDO
3. UNDO.
1. The analysis step:
o Identifies the dirty pages in the buffer by the set of transactions active at the
time of the crash.
o The appropriate point in the log where the REDO Operation should start is
also determined.
7) What are the anomalies occurring due to interleave execution? Explain them with
example.