1 / 33

Locks with Constrained Sharing

Locks with Constrained Sharing. Presentation by Maya Arbel for Seminar in Distributed Algorithms Spring 2013. Model. A database is a collection of objects . Users invokes transactions .

sherry
Download Presentation

Locks with Constrained Sharing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Locks with Constrained Sharing Presentation by Maya Arbel for Seminar in Distributed Algorithms Spring 2013

  2. Model • A databaseis a collection of objects. • Users invokes transactions. • A transaction is a sequence of read and write operations that are executed atomically on the objects.

  3. Correctness Criteria • Consider a set of transactions T • A historyH over T is the order in which all operations of transactions in T were executed, denoted by . • A serialhistoryis a history such that for every pair of transactions and either all operations executed by precede all operations executed by or vice versa.

  4. Correctness Criteria • Two operations conflictif they both operate on the same object, and one of them is a write. • A history is conflict-preserving serializableif there exists some serial history • over the same set of transactions • if and conflict and then . • The class of all conflict-preserving serializable histories is denoted as CPSR.

  5. Example  

  6. Checking For Correctness • We can determine whether a history is serializable by analyzing the serialization graph. • The serialization graph for , denoted • nodes are transactions in • edges if one of s operations precedes and conflicts with one of s operations. • A history is conflict-preserving serializable is acyclic.

  7. Checking For Correctness Example  

  8. Real Time Order and Conflict-Preserving Serializability • CPSR does not preserve real time order of operations.

  9. Locking and Locking Protocols • In the locking approach, each object has associated with it a read and a write lock. • Before a transaction can execute an operation it must acquire a lock of its type. Lock holder Lock requester

  10. Locking Protocol • A protocol is a set of rules on the manner in which locks are acquired. • The goal is to define a protocol such that all histories that are produced by the protocol are conflict-preserving serializable.

  11. Two Phase Locking Protocol (2PL) • Atransaction is not allowed to acquire any locks once it has released a single lock. • Separate the transaction into a locking phase and a release phase.

  12. Correctness of 2PL • Theorem 1: For any history produced by the two phase locking protocol is acyclic. • Proof: Later in the lecture.

  13. Limitations of 2PL • The following history is conflict serializable but do not follow the 2PL protocol. • We would like to find a protocol that captures both the conflict and the order relationship between operations. must release its lock on object before acquiring a lock on object .

  14. Ordered Sharing • Three locking modes: shared, ordered sharedand exclusive. • An ordered shared relationship between and , implies that if two transactions acquire these locks in some order, the operations must be executed in the same order. • Ordered sharing is denoted by .  

  15. Ordered Sharing • Assume , a lock is saidto be on holdif it was acquired by a transaction after another transaction had acquired , but before hasreleased the lock on . is on hold …

  16. Ordered Sharing Locking Tables

  17. Ordered Sharing Protocol • An extension of the 2PL protocol i.e., a transaction may not acquire a lock on any object once it has relinquished at least one lock. • Not enough, example (using table ): • Lock Relinquishing Rule: A transaction may not release any locks as long as any of its locks are on hold.

  18. Correctness of Ordered Sharing • Lemma 1: If then there exists an unlock operation such that for all unlock operations . • Proof: , 

  19. Correctness of Ordered Sharing • Lemma 1: If then there exists an unlock operation such that for all unlock operations . • Proof: ,  is on hold until Lock Relinquishing Rule

  20. Correctness of Ordered Sharing • Lemma 2: If there is a path then there exists an unlock operation such that for all unlock operations • Proof: By induction on n. • The base case follows from Lemma 1. • Assume correctness for 

  21. Correctness of Ordered Sharing • Theorem 2: For any history produced by the two phase locking protocol with ordered shared locks is acyclic • Proof: Assume there exists a cycle • Note: This proof also holds for 2PL without ordered shared locks • Contradiction!

  22. Ordered Sharing Locking Tables

  23. Relationship of Lock Tables

  24. Relationship of Lock Tables • Let be a 2PL protocol with ordered sharing using one of the lock tables except . • Let be a 2PL protocol with ordered sharing using a table with at least one more ordered sharing entrance then . • Theorem 3: Every history produced by must also been produced by .

  25. Relationship of Lock Tables • Theorem 3: Every history produced by must also been produced by . • Proof: assume • The ordered sharing acquisition rule: then 

  26. Relationship of Lock Tables • Theorem 3: Every history produced by must also been produced by . • Proof: assume • The lock relinquishing rule. then 

  27. Relationship of Lock Tables

  28. A Protocol for Conflict Preserving Serializability • Theorem 4: • Proof: • follows immediately from Theorem 2. • : Let be a history such that We will show lock and unlock steps for that follow • As allows locking at any point locks can be obtained immediately preceding the operations in . • The is acyclic thus induces an order on let this order be Order all unlock operations after all operations in according to the order .

  29. Deadlocks • 2PL protocol is not deadlock free • Example: both write to variables . • 2PL with ordered sharing is not deadlock free • Example: both are on hold:

  30. Implementation of Ordered Sharing Protocol • Each object maintains a FIFO queue of transactions. • Acquiring a lock is implemented as a enqueue operation. • The transaction at the top of the queue is the only one that can operate on the object. • A transaction is on hold if it is in an object’s queue but not as the top transaction. • Unlock operation is a dqueue operation and is only permitted if the transaction is not on hold.

  31. Summary • The use of locking protocols to achieve conflict-preservingserializable histories of concurrent programs. • A family of protocols, the most permissive recognizes all conflict-preserving serializable histories.

  32. References • Conflict serializability: • P. A. Bernstein, D. W. Shipman, and W. S. Wong. Formal aspects of serializability in database concurrency control. • C. H. Papadimitriou. The serializabilityof concurrent database updates. • Two phase locking: • K. P. Eswaran, J. N. Gray, R. A. Lorie, and I. L.Traiger. The Notion of Consistency and Predicate Locks in Database System. • Ordered sharing: • D.Agrawaland A.E.Abbadi. Locks with Constrained Sharing.

  33. Questions ?

More Related