1.Whitlock Department Stores runs a multiuser DBMS on a LAN file server. Unfortunately, at the present time, the DBMS does not enforce concurrency control. One Whitlock customer had a balance due of $500 when the following three transactions related to this customer were processed at the same time:
T1: Payment of $500T2: Purchase on credit of $100T3: Merchandise return (credit) of $50
a. In a real-world setting, serialization is enforced. What balance should be included for the customer after the three transactions execute in the given order? What will happen if they execute in a different order?
b. In this example concurrency control is not enforced and each of the three transactions reads the customer record when the balance was $500 (i.e., before any of the other transactions were completed). What balance will be included for the customer after the last transaction is completed (in the given order)?
c. Apply the standard two-phase locking protocol in the case above. How would that work? Does a deadlock occur?
d. Apply the versioning protocol. How would that work? Does any of the transactions rollback?
2. You are given two variables x and y, with original values x= 5 and y = 10 and two transactions T1 and T2 with the following steps:
T1: BEGIN TRANSACTION
Read x
x = x + 2
Write x commit x
Read y
y = y+5
write y commit y
T2: BEGIN TRANSACTION
Read x
x = x*3
Write x commit x
Read y
y = y+2
write y commit y
You also know the timeline for transaction 1:
A.Assuming that the database enforces no concurrency control, what will the final values for x and y be if transaction T2 begins at t1?
B.Assuming that the database enforces no concurrency control, what will the final values for x and y be if transaction T2 begins at t5?
C.Now assuming that the standard two-phase locking protocol is used to enforce serializability. If transaction T2 begins at t4, what will happen? At which timepoint will T2 be able to read x and at which timepoint will it write y? To answer this question, it is best if you draw the timeline of the two transactions, i.e. complete the above diagram with the T2 steps. What will the final values for x and y be?
D.Answer the same question if Transaction T2 begins at t1.
E.What will the timeline of the two transactions be if versioning is enforced? What will the final values for x and y be? At which timepoint?
Reviews
There are no reviews yet.