15s - CHAPTER 15 Concurrency Control Practice Exercises...

Info icon This preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
C H A P T E R 15 Concurrency Control Practice Exercises 15.1 Answer: Suppose two-phase locking does not ensure serializability. Then there exists a set of transactions T 0 , T 1 ... T n 1 which obey 2PL and which produce a nonserializable schedule. A non-serializable schedule implies a cycle in the precedence graph, and we shall show that 2PL cannot produce such cycles. Without loss of generality, assume the following cycle exists in the precedence graph: T 0 T 1 T 2 ... T n 1 T 0 . Let H9251 i be the time at which T i obtains its last lock (i.e. T i ’s lock point). Then for all transactions such that T i T j , H9251 i < H9251 j . Then for the cycle we have H9251 0 < H9251 1 < H9251 2 < ... < H9251 n 1 < H9251 0 Since H9251 0 < H9251 0 is a contradiction, no such cycle can exist. Hence 2PL cannot produce non-serializable schedules. Because of the property that for all transactions such that T i T j , H9251 i < H9251 j , the lock point ordering of the transactions is also a topological sort ordering of the precedence graph. Thus transactions can be serialized according to their lock points. 15.2 Answer: a. Lock and unlock instructions: T 34 : lock-S ( A ) read ( A ) lock-X ( B ) read ( B ) if A = 0 then B : = B + 1 write ( B ) unlock ( A ) unlock ( B ) 1
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2 Chapter 15 Concurrency Control T 35 : lock-S ( B ) read ( B ) lock-X ( A ) read ( A ) if B = 0 then A : = A + 1 write ( A ) unlock ( B ) unlock ( A ) b. Execution of these transactions can result in deadlock. For example, consider the following partial schedule: T 31 T 32 lock-S( A ) lock-S( B ) read( B ) read( A ) lock-X ( B ) lock-X ( A ) The transactions are now deadlocked. 15.3 Answer: Rigorous two-phase locking has the advantages of strict 2PL. In addition it has the property that for two conflicting transactions, their commit order is their serializability order. In some systems users might expect this behavior. 15.4 Answer: Consider two nodes A and B , where A is a parent of B . Let dummy vertex D be added between A and B . Consider a case where transaction T 2 has a lock on B , and T 1 , which has a lock on A wishes to lock B , and T 3 wishes to lock A . With the original tree, T 1 cannot release the lock on A until it gets the lock on B . With the modified tree, T 1 can get a lock on D , and release the lock on A , which allows T 3 to proceed while T 1 waits for T 2 . Thus, the protocol allows locks on vertices to be released earlier to other transactions, instead of holding them when waiting for a lock on a child. A generalization of idea based on edge locks is described in Buckley and Silberschatz, Concurrency Control in Graph Protocols by Using Edge Locks, Proc. ACM SIGACT-SIGMOD Symposium on the Principles of Database Systems, 1984. 15.5 Answer: Consider the tree-structured database graph given below.
Image of page 2
Practice Exercises 3 a99 A a99 B a99 C Schedule possible under tree protocol but not under 2PL : T 1 T 2 lock (A) lock (B) unlock (A) lock (A) lock (C) unlock (B) lock (B) unlock (A) unlock (B) unlock (C) Schedule possible under 2PL but not under tree protocol: T 1 T 2 lock (A) lock (B) lock (C) unlock (B) unlock (A) unlock (C) 15.6 Answer: The proof is in Kedem and Silberschatz, Locking Protocols: From Exclu- sive to Shared Locks, JACM Vol. 30, 4, 1983. (The proof of serializability
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern