DOC PREVIEW
UVA CS 4620 - Concurrency Control

This preview shows page 1-2-3-4-29-30-31-32-33-60-61-62-63 out of 63 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 63 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 63 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 63 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 63 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 63 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 63 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 63 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 63 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 63 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 63 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 63 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 63 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 63 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 63 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Concurrency ControlTwo-Phase Locking (2PL)Lock ManagementDeadlocksSlide 11Deadlock Detection by WFGDeadlock Detection using WFGSlide 14Deadlock PreventionDeadlock Prevention using TimestampsPerformance IssuesMultiple-Granularity LocksSolution: New Lock ModesMultiple Granularity Lock ProtocolSlide 21Dynamic DatabasesThe Phantom ProblemIndex LockingPredicate LockingLocking in B+ TreesTwo Useful ObservationsA Simple Tree Locking AlgorithmSlide 30A Better Tree Locking AlgorithmSlide 32Slide 35Seen on actual product packagesOptimistic CC (Kung-Robinson)Kung-Robinson ModelValidationTest 1Test 2Test 3Slide 43Comments on Serial ValidationOverheads in Optimistic CC``Optimistic’’ 2PLSlide 48Break TimeTimestamp OrderingSlide 51Basic Timestamp OrderingWhen T wants to read Object OWhen T wants to Write Object OTimestamp CC and RecoverabilityExercise: Non-equivalence of 2PL and TORelationship between 2PL and TOSlide 58The Digital Michelangelo ProjectMulti-version Data ObjectsMulti-version Timestamp OrderingMultiversion Timestamp OrderingReader XactWriter XactSlide 67Slide 68SummarySummary (Contd.)Slide 71Slide 72Slide 73QoS Differentiation Example Image Compression1Concurrency ControlChapter 176Two-Phase Locking (2PL)Two-Phase Locking ProtocolEach Xact must obtain a S (shared) lock on object before reading, and an X (exclusive) lock on object before writing.A transaction can not request additional locks once it releases any locks. If an Xact holds an X lock on an object, no other Xact can get a lock (S or X) on that object.9Lock ManagementLock and unlock requests are handled by the lock managerLock table entry:Number of transactions currently holding a lockType of lock held (shared or exclusive)Pointer to queue of lock requestsLocking and unlocking have to be atomic operationsLock upgrade: transaction that holds a shared lock can be upgraded to hold an exclusive lock10DeadlocksDeadlock: Cycle of transactions waiting for locks to be released by each other.T1=r1(x)w1(y)C1; T2=r2(y)w2(x)C2How can a deadlock occur?Four conditions for deadlock:Mutual exclusionHold and waitNo preemptionCircular waitAre they necessary conditions, sufficient, or necessary and sufficient conditions?11DeadlocksThree ways of dealing with deadlocks:Deadlock detection and resolution Deadlock preventionDeadlock avoidanceDeadlock detectionTime-out: no detection, just guessingChances of aborting a transaction that is not involved in a deadlockWait-for graphPrecise detectionLarge overhead12Deadlock Detection by WFGCreate a waits-for graph:Nodes are transactionsThere is an edge from Ti to Tj if Ti is waiting for Tj to release a lockPeriodically check for cycles in the waits-for graph --- How often?13Deadlock Detection using WFGExample:T1: S(A), R(A), S(B)T2: X(B),W(B) X(C)T3: S(C), R(C) X(A)T4: X(B)T1 T2T4 T3T1 T2T4 T314DeadlocksThree ways of dealing with deadlocks:Deadlock detection and resolution Deadlock preventionDeadlock avoidanceDeadlock detectionTime-out: no detection, just guessingChances of aborting a transaction that is not involved in a deadlockWait-for graphPrecise detectionLarge overhead15Deadlock PreventionPriority-based scheme: allow Ti wait for Tj only if Ti has a higher priority than Tj. Otherwise, abort Ti.Deadlock is not possible. Why? If T1->T2-> … ->Tn->T1 in WFG, then P(T1)>P(T2) ..>P(Tn)>P(T1)Typically implemented by using timestamp -- Assign priorities based on timestamps.TimestampsA monotonically increasing numberFinite number of smaller timestampsPriority of T is the inverse of its timestamp. Why?16Deadlock Prevention using TimestampsAssign priorities based on timestamps. Assume Ti wants a lock that Tj holds. Two policies are possible:Wait-Die: It Ti has higher priority, Ti waits for Tj; otherwise Ti abortsWound-wait: If Ti has higher priority, Tj aborts; otherwise Ti waitsIn both cases, younger transaction is aborted. Why?If a transaction re-starts, make sure it has its original timestamp. Why?17Performance IssuesThrashingResource contentionData contention PolicyBlocking policy vs restart policyIf low resource contention but severe data contention -- which policy will perform better?Restart policy – surprising?Blocking is selfish, restarting is self-sacrificingImpact of granularity on performanceTree locking – why important?18Multiple-Granularity LocksWhy consider it?Database consists of tables, pages, tuples (records)Hard to decide what granularity to lock (tuples vs. pages vs. tables).Shouldn’t have to decide. How?Data “containers” are nested: TuplesTablesPagesDatabasecontains19Solution: New Lock ModesHow to ensure that a page is not locked if another T holds a conflicting lock on the table?Exploit hierarchical nature: lock at each level, using new “intention” locks.Before locking an item, T must set “intention locks” on all its ancestors.For unlock, go from specific to general (i.e., bottom-up).SIX mode: Like S & IX at the same time.--IS IX--ISIX S XSX  20Multiple Granularity Lock ProtocolEach T starts from the root of the hierarchy.To get S or IS lock on a node, must hold IS or IX on parent node.What if T holds SIX on parent? S on parent?To get X or IX or SIX on a node, must hold IX or SIX on parent node.When can a lock released? To ensure SR, multi-granularity locking must be used with 2PL, which dictates when a lock can be releasedMust release locks in bottom-up order.21ExampleT1 scans R, and updates a few tuples:T1 gets an SIX lock on R, then repeatedly gets an S lock on tuples of R, and occasionally upgrades to X on the tuples.T2 uses an index to read only part of R:T2 gets an IS lock on R, and repeatedly gets an S lock on tuples of R.T3 reads all of R:T3 gets an S lock on R. OR, T3 could behave like T2; can use lock escalation.--IS IX--ISIX S XSX  22Dynamic DatabasesIf we relax the assumption that the DB is a fixed collection of objects, even Strict 2PL will not assure serializability. Why?T1 locks all pages containing sailor records with rating = 1, and finds oldest sailor (say, age = 71).Next, T2 inserts a new sailor; rating = 1, age = 96.T2 also


View Full Document

UVA CS 4620 - Concurrency Control

Download Concurrency Control
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Concurrency Control and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Concurrency Control 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?