Question: QUESTION B2. (10 marks) (a) (6 marks) Consider a database with objects A, B and C, and the following two trans- actions Ti and T2
QUESTION B2. (10 marks) (a) (6 marks) Consider a database with objects A, B and C, and the following two trans- actions Ti and T2 involving those objects: T1 begin transaction T2 read (A) read (B) read(C) begin transaction read (A) read (B) read (C) C := C+1 write (B) write (C) commit rite (A) rite (C) commit Let the initial values of A, B and C be 0; and the consistency requirement be: either A 0 or B 0. (i) Show that every serial execution of these two transactions preserves the consis- tency of the database (ii) Give an example of a non-serial schedule involving all the operations that con- stitute transactions T and T2 such that it (the non-serial schedule schedule you constructed) results in a lost update problem. observe the two-phase locking protocol (2PL) problem as identified in(i) above. (iii) Add lock and unlock instructions to the transaction Ti and T2 so that they (iv) Explain how the use of two-phase locking protocol can resolve the lost update (b) (4 marks) Discuss whether any concurrent execution of the two transactions Ti and T2 shown in part (a) can result in a deadlock. In your answer focus only on the lock/unlock instructions that you have introduced in part ai). If there is a deadlock, describe how could it have been prevented, if at all
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
