1 / 24

Optimistic Methods for Concurrency Control

Optimistic Methods for Concurrency Control. By: H.T. Kung and John Robinson Presented by: Frederick Ramirez. Roadmap. Introduction Locking Optimistic Concurrency Validation Serial Validation Parallel Validation Conclusion Questions?. Introduction.

dexter
Download Presentation

Optimistic Methods for Concurrency Control

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. Optimistic Methods for Concurrency Control By: H.T. Kung and John Robinson Presented by: Frederick Ramirez

  2. Roadmap • Introduction • Locking • Optimistic Concurrency • Validation • Serial Validation • Parallel Validation • Conclusion • Questions?

  3. Introduction • Concurrency control is the management of contention for data resources • There are two general approaches to concurrency control: locking and backup. The more popular approach are based on locking schemes • This paper investigates solutions to concurrency control relying almost entirely on a backup mechanism • The authors identify a number of inherent disadvantages of locking and proposes an optimistic approach

  4. Optimistic Approach • ”Optimistic”, because it is based on the observation that, in most applications, the likelihood of two transactions accessing the same object is low • The approach “hopes” that conflicts do not occur and transactions are allowed to proceed as though there were no possibility of conflict • Objective is to minimize the time over which a given resource would be unavailable for use by other transactions • A concurrency control scheme is considered pessimistic when it locks a given resource early in the data-access transaction and does not release it until the transaction is closed

  5. Target set • Consider the problem of providing shared access to a database organized as a collection of objects • If the goal is to maximize throughput of accesses, then there are at least two cases where highly concurrent access is desirable: • 1) The amount of data is sufficiently great that at any given time only a fraction of the database can be present in memory • 2) Even if the entire database can be present in memory, there may be multiple processors

  6. Disadvantages of Locking • Description: A mechanism where one process can deny certain processes access to some portion of the DB • Disadvantages: • Lock maintenance represents overhead • There are no general-purpose deadlock-free locking protocols for DBs w/ high concurrency • Concurrency is significantly lowered whenever it is necessary to leave some congested node locked • Locks cannot be released until the end of the transaction

  7. Disadvantages of Locking continued • Disadvantages: • Locking may be necessary only in the worst case

  8. Optimistic Concurrency Control • Kung and Robinson proposes two families of optimistic concurrency control which eliminate the use of locking. • This approach provides the following Advantages: • It is deadlock free • Avoids any time consuming node-locked scenarios • If the transactions become query dominant, the concurrency control overhead becomes almost negligible

  9. continued • Advantages • The approach is completely general. It applies equally well to any shared directed graph structure and associated access algorithm

  10. Idea behind Optimistic Approach • Since reading a value or a pointer from a node can never cause a loss of integrity, reads are completely unrestricted • Writes are severely restricted. • Transactions consist of three phases: • Read Phase: All writes take place on local copies of the object to be modified • Validations Phase: The step in which it is determined that the transaction will not cause a loss of integrity • Write Phase: Copies are made global

  11. Read and Write Phase • Read is also referred to as the “Working Phase” • Each transaction has a tentative version of each of the object that it updates • READ operations are performed immediately • WRITE operations record the new values of the objects as tentative values • Two records are kept of the objects accessed within a transaction: a read set and a write set

  12. Read and Write Phase • If validation succeeds, then the transaction enters the write phase • After write phase, all written values become “global” • When a transaction completes, it will request its validation and write phases via transactionEnd’ call

  13. Validation Phase • Uses a particularly strong form of validation • This is especially important with long-running transactions • Method uses an overqualified update scheme to test whether the underlying data source has been updated by another transaction since the beginning of the current transaction • Kung and Robinson employ Serial Equivalence for verifying the correctness of concurrent execution of transactions.

  14. Idea behind Correctness Criterion • Each transaction is assumed to have been written so as to individually preserve integrity of the data structure • If Tinitial satisfies all integrity criteria and the concurrent execution of T1, T2,…,Tn are serially equivalent from (1), by repeated application of the integrity-preserving property, Tfinal satisfies all integrity criteria • It is much easier to verify the two items above than it is to verify directly that every concurrent execution of transactions preserves integrity of the DB

  15. Validation of Serial Equivalence • Explicitly assigns each transaction a Transaction Number , t(i), at the end of the read phase • Transaction numbers are assigned in order, If the transaction is validated and completes successfully, it retains this number • If it fails the validation checks and is aborted, or if the transaction is read-only, the number is released for reassignment • Transaction numbers are integers assigned in ascending sequence • The number of a transaction defines its position in time • Tid satisfies the following property: t(i)<t(j) • Operations conform to the following validation conditions: • Ti must not read objects being written by Tj • Tj must not read objects being written by Ti • Ti must not write objects being written by Tj and Tj must not write objects being written by Ti

  16. Working Validation Update T 1 Earlier committed transactions T 2 T 3 Transaction T being validated v Figure 12.28 active 1 Later active active 2 transactions •

  17. The earlier committed transactions are T1, T2 and T3.T1 committed before Tv started. (earlier means they started validation earlier) • T2 and T3 committed before Tv finished its working phase • Validation consists of comparing the READ set of Tv with the write set of T2 and T3 • Conflicts are resolved by aborting the transaction undergoing validation • If transaction being validated does not have any read operations, it does not have to be checked • Optimistic concurrency requires that the write sets of old committed versions of objects corresponding to recently committed transactions are retained until there are no unvalidated overlapping transactions which might conflict • When a transaction is successfully validated, its transaction number and write set are recorded in a list that is maintained by the transaction service

  18. Considerations to Model • Case 1: A transaction T has an arbitrarily long read phase • Case 2: What should be done when validation fails? • Case 3: What should be done in the case where validation continually fails?

  19. Serial Validation • First of the two families of concurrency controls proposed by Kung and Robinson • This model implements validation conditions (1) and (2) of serial equivalence • When no two transactions may overlap in the write phase, condition 3 is satisfied (Implies write phase is serial execution) • Implementation consists of placing the assignment of Tid, validation, and subsequent write phase all in a critical section

  20. Parallel Validation • Concurrency control that uses all three of the validation conditions • Retains optimization properties of Serial Validation • Extends validation to allow multiple transactions to be in the validation phase at the same time • Condition 3 must be satisfied as well as condition 2. The write set of the transaction being validated must be checked for overlaps with the write set of earlier overlapping transactions

  21. Parallel Validation • tend:=( • <finish tn:=tnc; • finish active:=(make a copy of active) • active:=active U {id of this transaction} • valid:=true; • fortfromstart tn+1tofinish tndo • if (write set of transaction with transaction number t intersects read set) • thenvalid:=false; • for i E finish active do • if (write set of transaction Ti intersects read set or write set) • thenvalid:= false; • ifvalid • then( • (write phase); • <tnc:=tnc+1; • tn:=tnc; • active:=active—{id of this transaction}>; • (cleanup)) • else( • <active:=active—{id of transaction}>; • (backup)))

  22. Applications • Query dominant searches • Large Tree structured indexes • Ex: B-Trees

  23. Conclusion • In a locking approach, transactions are controlled by having them wait at certain points, while in an optimistic approach, transactions are controlled by backing them up • In a locking approach, serial equivalence can be proven by partially ordering the transactions by first access time for each object, while in an optimistic approach, transactions are ordered by transaction number assignment • The major difficulty in locking approaches is deadlock, in an optimistic approach, the major difficulty is starvation

More Related