CS 839: Design the Next-Generation Database Lecture 2:...
Transcript of CS 839: Design the Next-Generation Database Lecture 2:...
![Page 1: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/1.jpg)
Xiangyao Yu1/23/2020
CS 839: Design the Next-Generation DatabaseLecture 2: Transaction Basics
1
![Page 2: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/2.jpg)
AnnouncementsCourse website
http://pages.cs.wisc.edu/~yxy/cs839-s20/index.html
Email me if you are not in HotCRPhttps://wisc-cs839-ngdb20.hotcrp.com
2
![Page 3: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/3.jpg)
Today’s AgendaOLTP vs. OLAP
ACID properties• Atomicity
• Consistency
• Isolation
• Durability
3
![Page 4: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/4.jpg)
OLTP vs. OLAPOLTP: On-Line Transaction Processing• Users submit transactions that contain simple read/write operations• Example: banking, online shopping, etc.
OLAP: On-Line Analytical Processing• Complex analytics queries that reveal insights behind data• Example: business report, marketing, forecasting, etc.
4
![Page 5: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/5.jpg)
OLTP vs. OLAP
OLTP database
Transactions
(Update Intensive)
![Page 6: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/6.jpg)
OLTP vs. OLAP
OLTP database
Transactions
OLAP database(Update Intensive) (Read Intensive, rare updates)
6
![Page 7: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/7.jpg)
OLTP vs. OLAP
OLTP database
Transactions
OLAP database(Update Intensive) (Read Intensive, rare updates)
• Takes hours for conventional databases
• Takes seconds for Hybrid transactional/analytical processing (HTAP) systems
7
![Page 8: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/8.jpg)
OLTP vs. OLAP
OLTP database OLAP database(Update Intensive) (Read Intensive, rare updates)
This lecture Next lecture
8
![Page 9: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/9.jpg)
Transaction Definition
9
![Page 10: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/10.jpg)
Transaction DefinitionWhat are the required properties of a database transaction?
ACID
10
![Page 11: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/11.jpg)
Transaction DefinitionWhat are the required properties of a database transaction?
ACID
Example transactions:
If checking.balance > 100checking.balance -= 100saving.balance += 100
BeginRead(X)Write(Y)Insert(Z)Commit
11
![Page 12: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/12.jpg)
ACID: Atomicity
If checking.balance > 100
checking.balance -= 100
saving.balance += 100
Atomicity: Either all operations occur, or nothing occurs (All or nothing)
12
![Page 13: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/13.jpg)
ACID: ConsistencyIf checking.balance > 100
checking.balance -= 100saving.balance += 100
Consistency: Integrity constraints must be maintained.
Example Integrity constraint: balance of checking account must be above $0
Checking
Saving
$50
$1000
-$50
$1100RunTxn()
13
![Page 14: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/14.jpg)
ACID: DurabilityExample transaction:
If checking.balance > 100checking.balance -= 100saving.balance += 100
Checking
Saving
$1000
$1000
14
![Page 15: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/15.jpg)
ACID: DurabilityExample transaction:
If checking.balance > 100checking.balance -= 100saving.balance += 100
Checking
Saving
$1000
$1000
$900
$1100RunTxn()
15
![Page 16: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/16.jpg)
ACID: DurabilityExample transaction:
If checking.balance > 100checking.balance -= 100saving.balance += 100
Checking
Saving
$1000
$1000
$900
$1100RunTxn()
CRASH !!
???
???
16
![Page 17: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/17.jpg)
ACID: DurabilityExample transaction:
If checking.balance > 100checking.balance -= 100saving.balance += 100
Durability: A transaction’s updates persist in case of system failure
Checking
Saving
$1000
$1000
$900
$1100RunTxn()
CRASH !!
???
???
17
![Page 18: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/18.jpg)
ACID: Isolation
Initaillychecking.balance = 1000
18
![Page 19: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/19.jpg)
ACID: Isolation
If checking.balance > 100
bal = checking.balance
bal = bal – 100
checking.balance = bal
If checking.balance > 100
bal = checking.balance
bal = bal – 100
checking.balance = bal
Initaillychecking.balance = 1000
19
![Page 20: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/20.jpg)
ACID: Isolation
If checking.balance > 100
bal = checking.balance
bal = bal – 100
checking.balance = bal
If checking.balance > 100
bal = checking.balance
bal = bal – 100
checking.balance = bal
1
Initaillychecking.balance = 1000
bal = 1000
20
![Page 21: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/21.jpg)
ACID: Isolation
If checking.balance > 100
bal = checking.balance
bal = bal – 100
checking.balance = bal
If checking.balance > 100
bal = checking.balance
bal = bal – 100
checking.balance = bal
1 2
Initaillychecking.balance = 1000
bal = 1000 bal = 1000
21
![Page 22: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/22.jpg)
ACID: Isolation
If checking.balance > 100
bal = checking.balance
bal = bal – 100
checking.balance = bal
If checking.balance > 100
bal = checking.balance
bal = bal – 100
checking.balance = bal
1 2
Initaillychecking.balance = 1000
bal = 1000 bal = 1000
bal = 900 bal = 900
22
![Page 23: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/23.jpg)
ACID: Isolation
If checking.balance > 100
bal = checking.balance
bal = bal – 100
checking.balance = bal
If checking.balance > 100
bal = checking.balance
bal = bal – 100
checking.balance = bal
1 2
3
Initaillychecking.balance = 1000
bal = 1000 bal = 1000
bal = 900 bal = 900
checking = 90023
![Page 24: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/24.jpg)
ACID: Isolation
If checking.balance > 100
bal = checking.balance
bal = bal – 100
checking.balance = bal
If checking.balance > 100
bal = checking.balance
bal = bal – 100
checking.balance = bal
1 2
3 4
Initaillychecking.balance = 1000
bal = 1000 bal = 1000
bal = 900 bal = 900
checking = 900 checking = 90024
![Page 25: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/25.jpg)
ACID: IsolationStrong isolation: Serializability (Focus of this course)
Weak isolation: Snapshot Isolation, Read Committed, Read Uncommitted, etc.
Weaker isolation levels allow more interleaving of transactions
Schedule of concurrent transactions is equivalent to some serial schedule
25
![Page 26: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/26.jpg)
ACID: Isolation – Why Strong Isolation?
Attackers stole 896 Bitcoins ≈ 3 million US dollars
April 2014
MongoDB & Bitcoin: How NoSQL design flaws brought down two exchanges
Why you should pick strong consistency, whenever possible
Systems that don't provide strong consistency … create a burden for application developers
January 2018
SQL (before 2000) -> NoSQL (since 2000) -> NewSQL (since 2010s) 26
![Page 27: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/27.jpg)
How to Enforce ACIDAtomic & Isolation: Concurrency control
Consistency: Check integrity for transactions
Durability: Logging
27
![Page 28: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/28.jpg)
Concurrency Control
Pessimistic Optimistic
28
![Page 29: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/29.jpg)
Pessimistic – Two Phase Locking (2PL)T1
Begin
Read(X)
Write(Y)
Commit
29
Time
![Page 30: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/30.jpg)
Pessimistic – Two Phase Locking (2PL)T1
Begin
Read(X)
Write(Y)
Commit
30
Time
![Page 31: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/31.jpg)
Pessimistic – Two Phase Locking (2PL)T1
Begin
Read(X)
Write(Y)
Commit
31
Time
![Page 32: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/32.jpg)
Pessimistic – Two Phase Locking (2PL)T1
Begin
Read(X)
Write(Y)
Commit
Begin
Write(X)
T2
32
Time
![Page 33: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/33.jpg)
Pessimistic – Two Phase Locking (2PL)T1
Begin
Read(X)
Write(Y)
Commit
Begin
Write(X)
T2
33
Time
![Page 34: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/34.jpg)
Pessimistic – Two Phase Locking (2PL)T1
Begin
Read(X)
Write(Y)
Commit
Begin
Write(X)
Commit
T2
34
Time
![Page 35: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/35.jpg)
Pessimistic – Deadlock in 2PLT1
Begin
Read(X)
Write(Y)
Begin
Write(Y)
Write(X)
T2
35
Time
![Page 36: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/36.jpg)
Pessimistic – Deadlock in 2PLT1
Begin
Read(X)
Write(Y)
Begin
Write(Y)
Write(X)
T2
36
Time
![Page 37: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/37.jpg)
Pessimistic – Deadlock in 2PLT1
Begin
Read(X)
Write(Y)
Begin
Write(Y)
Write(X)
T2
37
Time
![Page 38: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/38.jpg)
Pessimistic – Deadlock in 2PLT1
Begin
Read(X)
Write(Y)
Begin
Write(Y)
Write(X)
T2
38
Time
![Page 39: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/39.jpg)
Pessimistic – Deadlock in 2PLT1
Begin
Read(X)
Write(Y)
Begin
Write(Y)
Write(X)
T2
39
Time
![Page 40: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/40.jpg)
Pessimistic – Deadlock in 2PLT1
Begin
Read(X)
Write(Y)
Begin
Write(Y)
Write(X)
T2
Deadlock ! 40
Time
![Page 41: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/41.jpg)
Pessimistic – Deadlock ResolutionT1
Begin
Read(X)
Write(Y)
Begin
Write(Y)
Write(X)
T2
Deadlock !
Detect and break cycles
Allow only certain waits• NoWait• WaitDie• WoundWait• LimitedDepth• etc.
41
Wait-for
Wait-for
![Page 42: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/42.jpg)
Optimistic Concurrency Control (OCC)T1
Begin
Read(X)
Write(Y)
Validate(X)
Abort
Begin
Write(X)
Commit
T2
42
Time
![Page 43: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/43.jpg)
How to Enforce ACIDAtomic & Isolation: Concurrency control
Consistency: Check integrity for transactions
Durability: Logging
43
![Page 44: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/44.jpg)
Durability: Logging
Begin
Initiallychecking = 1000
Write(Checking =
900)Commit
CRASH
Recovery Read(Checking = 900)
44
![Page 45: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/45.jpg)
Durability: Logging
Begin
Initiallychecking = 1000
Write(Checking =
900)Commit
CRASH
Recovery Read(Checking = 900)
Logging
T1 T2 T3 T4 T5Log(on disk)
…45
![Page 46: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/46.jpg)
SummaryA transaction in an OLTP system has ACID properties
Atomicity, Consistency, Isolation, Durability
Concurrency control (enforces Atomicity and Isolation)Two Phase Locking (2PL)Optimistic Concurrency Control (OCC)
Logging (enforces Durability)
46
![Page 47: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/47.jpg)
Group DiscussionDiscuss the relative advantages and disadvantages of 2PL and OCC.
What is your opinion on the debate between SQL and NoSQL (strong guarantee vs. high performance)?
Do you see any scalability problem with logging? If so, any potential solution?
47
![Page 48: CS 839: Design the Next-Generation Database Lecture 2: …pages.cs.wisc.edu/~yxy/cs839-s20/slides/L2.pdf · 2020-01-23 · Xiangyao Yu 1/23/2020 CS 839: Design the Next-Generation](https://reader034.fdocuments.us/reader034/viewer/2022050121/5f510962c9172c1fc5220bcc/html5/thumbnails/48.jpg)
Before Next LectureSubmit discussion summary to https://wisc-cs839-ngdb20.hotcrp.com• One summary per group• Authors: group members• Any format is ok (e.g., pdf, doc, txt)• Feel free to comment on others’ discussion
Submit review for[optional] C-Store: A Column-oriented DBMS
48