html5-img
1 / 10

Isolation

slides online at http://web.mit.edu/6.033/www/assignments/lec18.[ppt|pdf]. Isolation. 6.033 Spring 2010 Lecture 18 Sam Madden. Key concepts: Serial equivalence Two-phase locking Deadlock detection. Recover with cell-storage, log, cache, optimized cell-storage updates. recover(log):

zayit
Download Presentation

Isolation

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. slides online at http://web.mit.edu/6.033/www/assignments/lec18.[ppt|pdf] Isolation 6.033 Spring 2010 Lecture 18 Sam Madden Key concepts: Serial equivalence Two-phase locking Deadlock detection

  2. Recover with cell-storage, log, cache, optimized cell-storage updates recover(log): doneset = { } for each record r in log[len-1] ... log[0]: //UNDO if r.type == commit doneset = doneset U r.TID if r.type == update and r.TID not in doneset: write(cell-storage, r.var, r.before) for each record r in log[0]...log[len-1]: //REDO if r.type == update and r.TID in doneset: if (cell-storage does not reflect r) write(cell-storage, r.var, r.after)

  3. Conflicting Operations Given two transactions T1 and T2, and two operations o1 in T1, o2 in T2 o1 conflicts with o2 if either is a write and both are to the same object E.g. T1 RA, T2 WA or T1 WB, T2 WB

  4. Testing for Serial Equivalence (Conflict Serializability) A schedule is serial equivalent if • for all pairs of transactions T1 and T2, • all conflicting pairs of ops o1 in T1 and o2 in T2 are ordered the same way E.g., o1 always before o2 or o2 always before o1 Not serial equivalent! o1 T1 precedes T2 T1: RA WA T2: RA WA T1 precedes T2 T2 precedes T1 o2

  5. Locking Protocol Before reading/writing an object, get lock on it (If lock isn't available, block) When to release locks?

  6. Locking Protocol w/ Release Before reading/writing an object, system acquires lock on it (If lock isn't available, block) Release locks after transaction commit

  7. Two Phase Locking(Allows locks to be released before end of transaction) Phase 1 – system acquires lock before reading or writing an object, up to lock point Phase 2 – releases locks on objects, after done with them and after lock point (Never acquire locks in phase 2)

  8. Two-phase locking with shared and exclusive locks Phase 1: Before reading an object, system acquires an S lock on it Blocks if any other xaction has X lock on object Before writing an object, system acquires an X lock on it Blocks if any other xaction has X or S lock on object Phase 2: Release locks on objects, after done with them and after lock point

  9. Transaction Schedule  Log Schedule Log BEGIN T1 BEGIN T2 UPDATE T1,A UPDATE T2, A UPDATE T1, B UPDATE T2, B COMMIT T1; COMMIT T2 T1 T2 lock A RA lock A (block) WA lock B <--- lock point release A RA WA lock B (block) RB WB release B RB WB

  10. Avoiding cascading aborts Phase 1: Before reading an object, system acquires an S lock on it Blocks if any other xaction has X lock on object Before writing an object, system acquires an X lock on it Blocks if any other xaction has X or S lock on object Phase 2: Release S locks on objects anytime after done with them and after lock point Only release X locks after end of transaction

More Related