Presentation is loading. Please wait.

Presentation is loading. Please wait.

More on transactions…. Dealing with concurrency (OR: how to handle the pressure!) Locking Timestamp ordering Multiversion protocols Optimistic protocols.

Similar presentations


Presentation on theme: "More on transactions…. Dealing with concurrency (OR: how to handle the pressure!) Locking Timestamp ordering Multiversion protocols Optimistic protocols."— Presentation transcript:

1 More on transactions…

2 Dealing with concurrency (OR: how to handle the pressure!) Locking Timestamp ordering Multiversion protocols Optimistic protocols (validation protocol)

3 Timestamping: Wait-Die (1) If the younger transaction locks first: T1 - start at time-1 (older) T2 - start at time-2 (younger) T2 - request X lock on R T2 - write R - X lock T1 - request X lock on R - wait

4 Timestamping: Wait-Die (2) If the older transaction locks first: T1 - start at time-1 (older) T2 - start at time-2 (younger) T1 - request X lock on R T1 - write R - X lock T2 - request X lock on R - abort T1 - release X lock on R T2 - start again at time-2 (same timestamp, so it “looks older”)

5 Timestamping: Wound-Wait (1) If the younger transaction locks first: T1 - start at time-1 (older) T2 - start at time-2 (younger) T2 - request X lock on R T2 - write R - X lock T1 - request X lock on R T2 - abort T1 - write R - X lock T2 - start again at time-2

6 Timestamping: Wound-Wait (2) If the older transaction locks first: T1 - start at time-1 (older) T2 - start at time-2 (younger) T1 - request X lock on R T1 - write R - X lock T2 - request X lock on R - wait

7 Other concepts Cautious waiting – can only have one transaction waiting for each item Live lock – transaction can’t finish because it is always the youngest (might occur if tx didn’t keep the original timestamp) Timeout – assume that if waited longer than X time, deadlock exists, so tx are aborted

8 Transactions 1+ SQL statements that are performed completely, or not at all ACID properties –Atomic –Consistent –Isolation –Durability

9 Transaction Demo

10

11 Recovery

12 Types of Failures Transaction failure –Transaction must be aborted System failure –Hardware or software problem resulting in volatile memory loss Media failure –Disks or tapes Disasters

13 Transaction Logs Before image –Records previous values of objects before they were changed –Can be used to "undo" the transaction After image –Records new values after they've been changed –Can be used to "redo" the transaction

14 Logging changes System logs record activity of db (start of tx, operation performed, end of tx) Current block of log is in memory; when full, block is written to disk Changes can be force-written to disk "Write-ahead" logging Checkpoints are also recorded in log –Commit-consistent –Cache-consistent –Fuzzy

15 Logging changes (con'd) In-place updating Out-of-place updating –Shadowing Undo log may also be in volatile memory, so may need to be written to disk periodically

16 Commit processing No flush strategy Flush strategy No steal strategy Steal strategy Deferred update Immediate update How these strategies are combined determines what needs to be done in the event of failure Trade offs

17 Checkpoints in Oracle Mark that database is in a consistent state Oracle SCN Written to headers of database files and to control files

18 The Oracle SGA (Memory) System TS (Data Dictionary) Rollback segments Temporary Data1... Index1... Redo2 Redo3 Redo1 Arch1 Arch2 Arch3 Arch4 Arch5

19 TX recovery in Oracle Log scanned backward from end of log to most recent checkpoint. Undo uncommitted or aborted transactions. Log scanned forward from checkpoint. Redo all committed transactions. Take new checkpoint.

20 Transaction states CheckpointFailure T1 T2 T3 T4 T5 C C C TIME


Download ppt "More on transactions…. Dealing with concurrency (OR: how to handle the pressure!) Locking Timestamp ordering Multiversion protocols Optimistic protocols."

Similar presentations


Ads by Google