Presentation is loading. Please wait.

Presentation is loading. Please wait.

Databases & Consistency

Similar presentations


Presentation on theme: "Databases & Consistency"— Presentation transcript:

1 Databases & Consistency

2 Database Relational databases : dominant information storage/retrieval system

3 Activity…

4 Consistency Consistent : no contradictions

5 Consistency Inconsistent : contradictions

6 How Do we Become Inconsistent?
Only one row can be saved at a time… Make Rosina and Jingyi friends

7 How Do we Become Inconsistent?
Only one row can be saved at a time… Make Rosina and Jingyi friends

8 How Do we Become Inconsistent?
Only one row can be saved at a time… Make Rosina and Jingyi friends CRASH!!!!

9 Even Worse

10 Concurrency Issues Concurrency : two things happening at the same time
Many things are hard to share: Printers Shared memory

11 Concurrency Issues Race Condition : unpredictable result based on timing of concurrent operations

12 Concurrency Issues X starts as 5, 3 possible answers: Case 1 Case 2
A runs, x = 15 B runs, x =16 B runs, x = 6 A runs, x = 16 A gets x (5) B gets x (5) A adds 10 (has 15) B adds 1 (has 6) A stores x = 15 B stores x = 6 B gets x (5) A adds 10 (has 15) B adds 1 (has 6) B stores x = 6 A stores x = 15

13 Locks Can prevent concurrency problems with locks:

14 Atomicity Transaction must LOCK all rows it will modify before starting Want to transfer money from Marie to Pedro

15 Deadlock Workers A and B both want to use locked resources X and Y:

16 Deadlock Busting Database can resolve: Roll back one transaction
Give up its locks Make it restart AFTER other is complete

17 To Do List Trick Make a list of what you intend to do and save it:

18 To Do List Trick Make a list of what you intend to do and save it:

19 To Do List Trick Make a list of what you intend to do and save it:

20 To Do List Trick Delete list when you are done:

21 To Do List Trick A crash…

22 Idempotent Idempotent action : same effect no matter how many times you execute it "Change checking balance to $600" Non-idempotent "Subtract $200 from checking"

23 To Do List If every instruction is:
Idempotent Reversible : Know how to restore original state Can resume or reverse any partial transaction

24 Atomicity Atomic operation : indivisible / one unit
Never see results of half done transaction

25 Transactional Memory Current research area : Design regular software with transactional memory interactions


Download ppt "Databases & Consistency"

Similar presentations


Ads by Google