CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency...
Transcript of CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency...
![Page 1: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/1.jpg)
DATABASE SYSTEMS
Lecture #03 – Concurrency Control Challenges
15-721
@Andy_Pavlo // Carnegie Mellon University // Spring 2017
![Page 2: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/2.jpg)
CMU 15-721 (Spring 2017)
TODAY’S AGENDA
Transaction Models Concurrency Control Overview Many-Core Evaluation
2
![Page 3: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/3.jpg)
CMU 15-721 (Spring 2017)
TRANSACTION DEFINITION
A txn is a sequence of actions that are executed on a shared database to perform some higher-level function.
Txns are the basic unit of change in the DBMS. No partial txns are allowed.
3
![Page 4: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/4.jpg)
CMU 15-721 (Spring 2017)
ACTION CL ASSIFICATION
Unprotected Actions
→ These lack all of the ACID properties except for consistency. Their effects cannot be depended upon.
Protected Actions
→ These do not externalize their results before they are completely done. Fully ACID.
Real Actions
→ These affect the physical world in a way that is hard or impossible to reverse.
4
![Page 5: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/5.jpg)
CMU 15-721 (Spring 2017)
TRANSACTION MODELS
Flat Txns Flat Txns + Savepoints Chained Txns Nested Txns Saga Txns Compensating Txns
5
![Page 6: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/6.jpg)
CMU 15-721 (Spring 2017)
FL AT TRANSACTIONS
Standard txn model that starts with BEGIN, followed by one or more actions, and then completed with either COMMIT or ROLLBACK.
6
Txn #1
BEGIN
READ(A)
COMMIT
WRITE(B)
Txn #2
BEGIN
READ(A)
ROLLBACK
WRITE(B)
![Page 7: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/7.jpg)
CMU 15-721 (Spring 2017)
LIMITATIONS OF FL AT TRANSACTIONS
The application can only rollback the entire txn (i.e., no partial rollbacks).
All of a txn’s work is lost is the DBMS fails before that txn finishes.
Each txn takes place at a single point in time
7
![Page 8: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/8.jpg)
CMU 15-721 (Spring 2017)
LIMITATIONS OF FL AT TRANSACTIONS
Multi-Stage Planning → An application needs to make multiple reservations. → All the reservations need to occur or none of them.
Bulk Updates → An application needs to update one billion records. → This txn could take hours to complete and therefore the
DBMS is exposed to losing all of its work for any failure or conflict.
8
![Page 9: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/9.jpg)
CMU 15-721 (Spring 2017)
TRANSACTION SAVEPOINTS
Save the current state of processing for the txn and provide a handle for the application to refer to that savepoint. The application can control the state of the txn through these checkpoints: → ROLLBACK – Revert all changes back to the state of the
DB at the savepoint. → RELEASE – Destroys a savepoint previously defined in
the txn.
9
![Page 10: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/10.jpg)
CMU 15-721 (Spring 2017)
TRANSACTION SAVEPOINTS
10
Txn #1
BEGIN WRITE(A)
COMMIT
SAVEPOINT 1
WRITE(B) ROLLBACK TO 1
WRITE(C)
New Savepoint
![Page 11: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/11.jpg)
CMU 15-721 (Spring 2017)
TRANSACTION SAVEPOINTS
10
Txn #1
BEGIN WRITE(A)
COMMIT
SAVEPOINT 1
WRITE(B) ROLLBACK TO 1
WRITE(C)
A
New Savepoint
![Page 12: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/12.jpg)
CMU 15-721 (Spring 2017)
TRANSACTION SAVEPOINTS
10
Txn #1
BEGIN WRITE(A)
COMMIT
SAVEPOINT 1
WRITE(B) ROLLBACK TO 1
WRITE(C)
A New Savepoint
Savepoint#1
![Page 13: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/13.jpg)
CMU 15-721 (Spring 2017)
TRANSACTION SAVEPOINTS
10
Txn #1
BEGIN WRITE(A)
COMMIT
SAVEPOINT 1
WRITE(B) ROLLBACK TO 1
WRITE(C)
A New Savepoint
B
Savepoint#1
![Page 14: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/14.jpg)
CMU 15-721 (Spring 2017)
TRANSACTION SAVEPOINTS
10
Txn #1
BEGIN WRITE(A)
COMMIT
SAVEPOINT 1
WRITE(B) ROLLBACK TO 1
WRITE(C)
A New Savepoint
B New Savepoint X
Savepoint#1
![Page 15: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/15.jpg)
CMU 15-721 (Spring 2017)
TRANSACTION SAVEPOINTS
10
Txn #1
BEGIN WRITE(A)
COMMIT
SAVEPOINT 1
WRITE(B) ROLLBACK TO 1
WRITE(C)
A New Savepoint
B New Savepoint
C X
Savepoint#1
![Page 16: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/16.jpg)
CMU 15-721 (Spring 2017)
TRANSACTION SAVEPOINTS
10
Txn #1
BEGIN WRITE(A)
COMMIT
SAVEPOINT 1
WRITE(B) ROLLBACK TO 1
WRITE(C)
A New Savepoint
B New Savepoint
C X
Savepoint#1
![Page 17: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/17.jpg)
CMU 15-721 (Spring 2017)
TRANSACTION SAVEPOINTS
11
Txn #1
BEGIN WRITE(A)
SAVEPOINT 3
SAVEPOINT 1
WRITE(B) SAVEPOINT 2
WRITE(C)
ROLLBACK TO 3
RELEASE 2
WRITE(D)
![Page 18: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/18.jpg)
CMU 15-721 (Spring 2017)
TRANSACTION SAVEPOINTS
11
Txn #1
BEGIN WRITE(A)
SAVEPOINT 3
SAVEPOINT 1
WRITE(B) SAVEPOINT 2
WRITE(C)
A
ROLLBACK TO 3
RELEASE 2
WRITE(D)
New Savepoint
![Page 19: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/19.jpg)
CMU 15-721 (Spring 2017)
TRANSACTION SAVEPOINTS
11
Txn #1
BEGIN WRITE(A)
SAVEPOINT 3
SAVEPOINT 1
WRITE(B) SAVEPOINT 2
WRITE(C)
A
ROLLBACK TO 3
RELEASE 2
WRITE(D)
Savepoint#1
New Savepoint
![Page 20: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/20.jpg)
CMU 15-721 (Spring 2017)
TRANSACTION SAVEPOINTS
11
Txn #1
BEGIN WRITE(A)
SAVEPOINT 3
SAVEPOINT 1
WRITE(B) SAVEPOINT 2
WRITE(C)
A
B
ROLLBACK TO 3
RELEASE 2
WRITE(D)
Savepoint#1
New Savepoint
![Page 21: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/21.jpg)
CMU 15-721 (Spring 2017)
TRANSACTION SAVEPOINTS
11
Txn #1
BEGIN WRITE(A)
SAVEPOINT 3
SAVEPOINT 1
WRITE(B) SAVEPOINT 2
WRITE(C)
A
B
ROLLBACK TO 3
RELEASE 2
WRITE(D)
Savepoint#1
Savepoint#2
New Savepoint
![Page 22: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/22.jpg)
CMU 15-721 (Spring 2017)
TRANSACTION SAVEPOINTS
11
Txn #1
BEGIN WRITE(A)
SAVEPOINT 3
SAVEPOINT 1
WRITE(B) SAVEPOINT 2
WRITE(C)
A
B
C
ROLLBACK TO 3
RELEASE 2
WRITE(D)
Savepoint#1
Savepoint#2
New Savepoint
![Page 23: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/23.jpg)
CMU 15-721 (Spring 2017)
TRANSACTION SAVEPOINTS
11
Txn #1
BEGIN WRITE(A)
SAVEPOINT 3
SAVEPOINT 1
WRITE(B) SAVEPOINT 2
WRITE(C)
A
B
C
ROLLBACK TO 3
RELEASE 2
WRITE(D)
New Savepoint
Savepoint#1
Savepoint#2
Savepoint#3
![Page 24: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/24.jpg)
CMU 15-721 (Spring 2017)
TRANSACTION SAVEPOINTS
11
Txn #1
BEGIN WRITE(A)
SAVEPOINT 3
SAVEPOINT 1
WRITE(B) SAVEPOINT 2
WRITE(C)
A
B
C
ROLLBACK TO 3
RELEASE 2
WRITE(D)
New Savepoint
Savepoint#1
Savepoint#3
![Page 25: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/25.jpg)
CMU 15-721 (Spring 2017)
TRANSACTION SAVEPOINTS
11
Txn #1
BEGIN WRITE(A)
SAVEPOINT 3
SAVEPOINT 1
WRITE(B) SAVEPOINT 2
WRITE(C)
A
B
C
ROLLBACK TO 3
RELEASE 2
WRITE(D)
New Savepoint
D
Savepoint#1
Savepoint#3
![Page 26: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/26.jpg)
CMU 15-721 (Spring 2017)
TRANSACTION SAVEPOINTS
11
Txn #1
BEGIN WRITE(A)
SAVEPOINT 3
SAVEPOINT 1
WRITE(B) SAVEPOINT 2
WRITE(C)
A
B
C
ROLLBACK TO 3
RELEASE 2
WRITE(D)
New Savepoint
D
???
Savepoint#1
Savepoint#3
![Page 27: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/27.jpg)
CMU 15-721 (Spring 2017)
TRANSACTION SAVEPOINTS
11
Txn #1
BEGIN WRITE(A)
SAVEPOINT 3
SAVEPOINT 1
WRITE(B) SAVEPOINT 2
WRITE(C)
A
B
C
ROLLBACK TO 3
RELEASE 2
WRITE(D)
New Savepoint
D
???
Savepoint#1
Savepoint#3
![Page 28: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/28.jpg)
CMU 15-721 (Spring 2017)
NESTED TRANSACTIONS
Savepoints organize a transaction as a sequence of actions that can be rolled back individually. Nested txns form a hierarchy of work. → The outcome of a child txn depends on the outcome of its
parent txn.
12
![Page 29: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/29.jpg)
CMU 15-721 (Spring 2017)
NESTED TRANSACTIONS
13
Txn #1
BEGIN WRITE(A) BEGIN
BEGIN WRITE(C) COMMIT
COMMIT
WRITE(B)
ROLLBACK WRITE(D)
BEGIN
![Page 30: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/30.jpg)
CMU 15-721 (Spring 2017)
NESTED TRANSACTIONS
13
Txn #1
BEGIN WRITE(A) BEGIN
BEGIN WRITE(C) COMMIT
COMMIT
WRITE(B)
ROLLBACK WRITE(D)
BEGIN
![Page 31: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/31.jpg)
CMU 15-721 (Spring 2017)
NESTED TRANSACTIONS
13
Txn #1
BEGIN WRITE(A) BEGIN
BEGIN WRITE(C) COMMIT
COMMIT
WRITE(B)
ROLLBACK WRITE(D)
BEGIN
![Page 32: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/32.jpg)
CMU 15-721 (Spring 2017)
Sub-Txn #1.1
NESTED TRANSACTIONS
13
Txn #1
BEGIN WRITE(A) BEGIN
BEGIN WRITE(C) COMMIT
COMMIT
WRITE(B)
ROLLBACK WRITE(D)
BEGIN
![Page 33: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/33.jpg)
CMU 15-721 (Spring 2017)
Sub-Txn #1.1
NESTED TRANSACTIONS
13
Txn #1
BEGIN WRITE(A) BEGIN
BEGIN WRITE(C) COMMIT
COMMIT
WRITE(B)
ROLLBACK WRITE(D)
BEGIN
![Page 34: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/34.jpg)
CMU 15-721 (Spring 2017)
Sub-Txn #1.1
NESTED TRANSACTIONS
13
Sub-Txn #1.1.1
Txn #1
BEGIN WRITE(A) BEGIN
BEGIN WRITE(C) COMMIT
COMMIT
WRITE(B)
ROLLBACK WRITE(D)
BEGIN
![Page 35: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/35.jpg)
CMU 15-721 (Spring 2017)
Sub-Txn #1.1
NESTED TRANSACTIONS
13
Sub-Txn #1.1.1
BEGIN
Txn #1
BEGIN WRITE(A) BEGIN
BEGIN WRITE(C) COMMIT
COMMIT
WRITE(B)
ROLLBACK WRITE(D)
BEGIN
![Page 36: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/36.jpg)
CMU 15-721 (Spring 2017)
Sub-Txn #1.1
NESTED TRANSACTIONS
13
Sub-Txn #1.1.1
BEGIN
Txn #1
BEGIN WRITE(A) BEGIN
BEGIN WRITE(C) COMMIT
COMMIT
WRITE(B)
ROLLBACK WRITE(D)
BEGIN
![Page 37: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/37.jpg)
CMU 15-721 (Spring 2017)
Sub-Txn #1.1
NESTED TRANSACTIONS
13
Sub-Txn #1.1.1
BEGIN
Txn #1
BEGIN WRITE(A) BEGIN
BEGIN WRITE(C) COMMIT
COMMIT
WRITE(B)
ROLLBACK WRITE(D)
BEGIN
X
X
X
![Page 38: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/38.jpg)
CMU 15-721 (Spring 2017)
Sub-Txn #1.1
NESTED TRANSACTIONS
13
Sub-Txn #1.1.1
BEGIN
Txn #1
BEGIN WRITE(A) BEGIN
BEGIN WRITE(C) COMMIT
COMMIT
WRITE(B)
ROLLBACK WRITE(D)
BEGIN
X
X
X
✓
![Page 39: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/39.jpg)
CMU 15-721 (Spring 2017)
TRANSACTION CHAINS
Multiple txns executed one after another. Combined COMMIT / BEGIN operation is atomic. → No other txn can change the state of the database as seen
by the second txn from the time that the first txn commits and the second txn begins.
Differences with savepoints: → COMMIT allows the DBMS to free locks. → Cannot rollback previous txns in chain.
14
![Page 40: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/40.jpg)
CMU 15-721 (Spring 2017)
TRANSACTION CHAINS
15
Txn #1
BEGIN WRITE(A) COMMIT Txn #2
BEGIN WRITE(B) COMMIT Txn #3
BEGIN WRITE(C) ROLLBACK
![Page 41: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/41.jpg)
CMU 15-721 (Spring 2017)
BULK UPDATE PROBLEM
These other txn models are nice, but they still do not solve our bulk update problem.
Chained txns seems like the right idea but they require the application to handle failures and maintain it’s own state. → Has to be able to reverse changes when things fail.
16
![Page 42: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/42.jpg)
CMU 15-721 (Spring 2017)
COMPENSATING TRANSACTIONS
A special type of txn that is designed to semantically reverse the effects of another already committed txn.
Reversal has to be logical instead of physical. → Example: Decrement a counter by one instead of
reverting to the original value.
17
![Page 43: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/43.jpg)
CMU 15-721 (Spring 2017)
SAGA TRANSACTIONS
A sequence of chained txns T1 ,…,T
n and
compensating txns C1,…,C
n-1 where one of the
following is guaranteed: →The txns will commit in the order
T1 ,…,Tn
→The txns will commit in the order T
1 ,…,T
j,C
j,…,C
1 (where j < n)
18
SAGAS SIGMOD, pp. 249-259, 1987.
![Page 44: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/44.jpg)
CMU 15-721 (Spring 2017)
SAGA TRANSACTIONS
19
Txn #1
BEGIN WRITE(A+1) COMMIT
Txn #2
BEGIN WRITE(B+1) COMMIT
Txn #3
BEGIN WRITE(C+1)
Comp Txn #1
BEGIN WRITE(A-1) COMMIT
Comp Txn #2
BEGIN WRITE(B-1) COMMIT
![Page 45: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/45.jpg)
CMU 15-721 (Spring 2017)
SAGA TRANSACTIONS
19
Txn #1
BEGIN WRITE(A+1) COMMIT
Txn #2
BEGIN WRITE(B+1) COMMIT
Txn #3
BEGIN WRITE(C+1)
Comp Txn #1
BEGIN WRITE(A-1) COMMIT
Comp Txn #2
BEGIN WRITE(B-1) COMMIT
![Page 46: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/46.jpg)
CMU 15-721 (Spring 2017)
CONCURRENCY CONTROL
The protocol to allow txns to access a database in a multi-programmed fashion while preserving the illusion that each of them is executing alone on a dedicated system. → The goal is to have the effect of a group of txns on the
database’s state is equivalent to any serial execution of all txns.
Provides Atomicity + Isolation in ACID
20
![Page 47: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/47.jpg)
CMU 15-721 (Spring 2017)
TXN INTERNAL STATE
Undo Log Entries
→ Stored in an in-memory data structure. → Dropped on commit.
Redo Log Entries
→ Append to the in-memory tail of WAL. → Flushed to disk on commit.
Read/Write Set
→ Depends on the concurrency control scheme.
21
![Page 48: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/48.jpg)
CMU 15-721 (Spring 2017)
CONCURRENCY CONTROL SCHEMES
Two-Phase Locking (2PL)
→ Assume txns will conflict so they must acquire locks on elements before they are allowed to access them.
Timestamp Ordering (T/O)
→ Assume that conflicts are rare so txns do not need to acquire locks and instead check for conflicts at commit time.
22
![Page 49: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/49.jpg)
CMU 15-721 (Spring 2017)
TWO-PHASE LOCKING
23
Txn #1
BEGIN
COMMIT
LOCK(A) LOCK(B) UNLOCK(A) UNLOCK(B) READ(A) WRITE(B)
Shrinking Phase
LOCK(A) LOCK(B)
Growing Phase
![Page 50: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/50.jpg)
CMU 15-721 (Spring 2017)
TWO-PHASE LOCKING
23
Txn #2
BEGIN
COMMIT
LOCK(B) LOCK(A) WRITE(A) UNLOCK(A) UNLOCK(B) WRITE(B)
Txn #1
BEGIN
COMMIT
LOCK(A) LOCK(B) UNLOCK(A) UNLOCK(B) READ(A) WRITE(B) LOCK(A) LOCK(B)
![Page 51: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/51.jpg)
CMU 15-721 (Spring 2017)
TWO-PHASE LOCKING
23
Txn #2
BEGIN
COMMIT
LOCK(B) LOCK(A) WRITE(A) UNLOCK(A) UNLOCK(B) WRITE(B)
Txn #1
BEGIN
COMMIT
LOCK(A) LOCK(B) UNLOCK(A) UNLOCK(B) READ(A) WRITE(B) LOCK(A) LOCK(B)
![Page 52: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/52.jpg)
CMU 15-721 (Spring 2017)
TWO-PHASE LOCKING
23
Txn #2
BEGIN
COMMIT
LOCK(B) LOCK(A) WRITE(A) UNLOCK(A) UNLOCK(B) WRITE(B)
Txn #1
BEGIN
COMMIT
LOCK(A) LOCK(B) UNLOCK(A) UNLOCK(B) READ(A) WRITE(B) LOCK(A) LOCK(B)
![Page 53: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/53.jpg)
CMU 15-721 (Spring 2017)
TWO-PHASE LOCKING
23
Txn #2
BEGIN
COMMIT
LOCK(B) LOCK(A) WRITE(A) UNLOCK(A) UNLOCK(B) WRITE(B)
Txn #1
BEGIN
COMMIT
LOCK(A) LOCK(B) UNLOCK(A) UNLOCK(B) READ(A) WRITE(B) LOCK(A) LOCK(B)
![Page 54: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/54.jpg)
CMU 15-721 (Spring 2017)
TWO-PHASE LOCKING
23
Txn #2
BEGIN
COMMIT
LOCK(B) LOCK(A) WRITE(A) UNLOCK(A) UNLOCK(B) WRITE(B)
Txn #1
BEGIN
COMMIT
LOCK(A) LOCK(B) UNLOCK(A) UNLOCK(B) READ(A) WRITE(B) LOCK(A) LOCK(B)
![Page 55: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/55.jpg)
CMU 15-721 (Spring 2017)
TWO-PHASE LOCKING
Deadlock Detection → Each txn maintains a queue of the txns that hold the locks
that it waiting for. → A separate thread checks these queues for deadlocks. → If deadlock found, use a heuristic to decide what txn to
kill in order to break deadlock.
Deadlock Prevention
→ Check whether another txn already holds a lock when another txn requests it.
→ If lock is not available, the txn will either (1) wait, (2) commit suicide, or (3) kill the other txn.
24
![Page 56: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/56.jpg)
CMU 15-721 (Spring 2017)
TIMESTAMP ORDERING
25
Txn #1
BEGIN
COMMIT
READ(A) WRITE(B) WRITE(A)
• • • • • • •
![Page 57: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/57.jpg)
CMU 15-721 (Spring 2017)
TIMESTAMP ORDERING
25
Record Read Timestamp
Write Timestamp
A
B 10000
Txn #1
BEGIN
COMMIT
READ(A) WRITE(B) WRITE(A)
• • • •
10000
10000
• • •
10000
10001
![Page 58: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/58.jpg)
CMU 15-721 (Spring 2017)
TIMESTAMP ORDERING
25
Record Read Timestamp
Write Timestamp
A
B 10000
Txn #1
BEGIN
COMMIT
READ(A) WRITE(B) WRITE(A)
• • • •
10001
10000
• • •
10000
10001
![Page 59: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/59.jpg)
CMU 15-721 (Spring 2017)
TIMESTAMP ORDERING
25
Record Read Timestamp
Write Timestamp
A
B 10000
Txn #1
BEGIN
COMMIT
READ(A) WRITE(B) WRITE(A)
• • • •
10001
10001
• • •
10000
10001
![Page 60: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/60.jpg)
CMU 15-721 (Spring 2017)
TIMESTAMP ORDERING
25
Record Read Timestamp
Write Timestamp
A
B 10000
Txn #1
BEGIN
COMMIT
READ(A) WRITE(B) WRITE(A)
• • • •
10001
10001
• • •
10005
10001
![Page 61: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/61.jpg)
CMU 15-721 (Spring 2017)
TIMESTAMP ORDERING
25
Record Read Timestamp
Write Timestamp
A
B 10000
Txn #1
BEGIN
COMMIT
READ(A) WRITE(B) WRITE(A)
• • • •
10001
10001
• • •
10005
10001
![Page 62: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/62.jpg)
CMU 15-721 (Spring 2017)
TIMESTAMP ORDERING
Basic T/O
→ Check for conflicts on each read/write. → Copy tuples on each access to ensure repeatable reads.
Optimistic Currency Control (OCC)
→ Store all changes in private workspace. → Check for conflicts at commit time and then merge.
Multi-Version Concurrency Control (MVCC)
→ Create a new version of a tuple whenever a txn modifies it. Use timestamps as version id.
→ Check visibility on every read/write.
26
![Page 63: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/63.jpg)
CMU 15-721 (Spring 2017)
CONCURRENCY CONTROL SCHEMES
27
DL_DETECT
NO_WAIT
WAIT_DIE
2PL w/ Deadlock Detection 2PL w/ Non-waiting Prevention 2PL w/ Wait-and-Die Prevention
TIMESTAMP
MVCC
OCC
Basic T/O Algorithm Multi-Version T/O Optimistic Concurrency Control
![Page 64: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/64.jpg)
CMU 15-721 (Spring 2017)
CONCURRENCY CONTROL SCHEMES
27
DL_DETECT
NO_WAIT
WAIT_DIE
2PL w/ Deadlock Detection 2PL w/ Non-waiting Prevention 2PL w/ Wait-and-Die Prevention
![Page 65: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/65.jpg)
CMU 15-721 (Spring 2017)
CONCURRENCY CONTROL SCHEMES
27
TIMESTAMP
MVCC
OCC
Basic T/O Algorithm Multi-Version T/O Optimistic Concurrency Control
![Page 66: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/66.jpg)
CMU 15-721 (Spring 2017)
1000-CORE CPU SIMUL ATOR
DBx1000 Database System → In-memory DBMS with pluggable lock manager. → No network access, logging, or concurrent indexes
MIT Graphite CPU Simulator → Single-socket, tile-based CPU. → Shared L2 cache for groups of cores. → Tiles communicate over 2D-mesh network.
28
STARING INTO THE ABYSS: AN EVALUATION OF CONCURRENCY CONTROL WITH ONE THOUSAND CORES VLDB, pp. 209-220, 2014.
![Page 67: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/67.jpg)
CMU 15-721 (Spring 2017)
TARGET WORKLOAD
Yahoo! Cloud Serving Benchmark (YCSB) → 20 million tuples → Each tuple is 1KB (total database is ~20GB)
Each transactions reads/modifies 16 tuples. Varying skew in transaction access patterns. Serializable isolation level.
29
![Page 68: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/68.jpg)
CMU 15-721 (Spring 2017)
READ-ONLY WORKLOAD
30
![Page 69: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/69.jpg)
CMU 15-721 (Spring 2017)
READ-ONLY WORKLOAD
30
![Page 70: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/70.jpg)
CMU 15-721 (Spring 2017)
READ-ONLY WORKLOAD
30
![Page 71: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/71.jpg)
CMU 15-721 (Spring 2017)
WRITE-INTENSIVE / MEDIUM-CONTENTION
31
![Page 72: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/72.jpg)
CMU 15-721 (Spring 2017)
WRITE-INTENSIVE / MEDIUM-CONTENTION
31
![Page 73: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/73.jpg)
CMU 15-721 (Spring 2017)
WRITE-INTENSIVE / MEDIUM-CONTENTION
31
![Page 74: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/74.jpg)
CMU 15-721 (Spring 2017)
WRITE-INTENSIVE / HIGH-CONTENTION
32
![Page 75: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/75.jpg)
CMU 15-721 (Spring 2017)
WRITE-INTENSIVE / HIGH-CONTENTION
32
![Page 76: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/76.jpg)
CMU 15-721 (Spring 2017)
WRITE-INTENSIVE / HIGH-CONTENTION
32
![Page 77: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/77.jpg)
CMU 15-721 (Spring 2017)
WRITE-INTENSIVE / HIGH-CONTENTION
32
![Page 78: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/78.jpg)
CMU 15-721 (Spring 2017)
BOT TLENECKS
Lock Thrashing
→ DL_DETECT, WAIT_DIE
Timestamp Allocation
→ All T/O algorithms + WAIT_DIE
Memory Allocations
→ OCC + MVCC
33
![Page 79: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/79.jpg)
CMU 15-721 (Spring 2017)
LOCK THRASHING
Each txn waits longer to acquire locks, causing other txn to wait longer to acquire locks.
Can measure this phenomenon by removing deadlock detection/prevention overhead. → Force txns to acquire locks in primary key order. → Deadlocks are not possible.
34
![Page 80: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/80.jpg)
CMU 15-721 (Spring 2017)
LOCK THRASHING
35
![Page 81: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/81.jpg)
CMU 15-721 (Spring 2017)
LOCK THRASHING
35
![Page 82: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/82.jpg)
CMU 15-721 (Spring 2017)
TIMESTAMP ALLOCATION
Mutex
→ Worst option.
Atomic Addition
→ Requires cache invalidation on write.
Batched Atomic Addition
→ Needs a back-off mechanism to prevent fast burn.
Hardware Clock
→ Not sure if it will exist in future CPUs.
Hardware Counter
→ Not implemented in existing CPUs.
36
![Page 83: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/83.jpg)
CMU 15-721 (Spring 2017)
TIMESTAMP ALLOCATION
37
![Page 84: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/84.jpg)
CMU 15-721 (Spring 2017)
MEMORY ALLOCATIONS
Copying data on every read/write access slows down the DBMS because of contention on the memory controller. → In-place updates and non-copying reads are not affected
as much.
Default libc malloc is slow. Never use it.
38
![Page 85: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/85.jpg)
CMU 15-721 (Spring 2017)
PARTITION-LEVEL LOCKING
The database is split up into horizontal partitions: → Each partition is assigned a single-threaded execution
engine that has exclusive access to its data. → In-place updates.
Only one txn can execute at a time per partition. → Order txns based on when they arrive at the DBMS. → A txn acquires the lock for a partition when it has the
lowest timestamp. → It is not allowed to access any partition that it does not
hold the lock for.
39
![Page 86: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/86.jpg)
CMU 15-721 (Spring 2017)
READ-ONLY WORKLOAD
40
![Page 87: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/87.jpg)
CMU 15-721 (Spring 2017)
MULTI-PARTITION WORKLOADS
41
![Page 88: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/88.jpg)
CMU 15-721 (Spring 2017)
PARTING THOUGHTS
Concurrency control is hard to get correct and perform well.
Evaluation did not consider HTAP workloads.
42
![Page 89: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/89.jpg)
CMU 15-721 (Spring 2017)
NEXT CL ASS
Isolation Levels Stored Procedures High-Performance OCC
43
![Page 90: CMU SCS 15-721 (Spring 2017) :: Concurrency Control Challenges · Lecture #03 – Concurrency Control Challenges . ... Txns are the basic unit of change in the DBMS. No partial txns](https://reader036.fdocuments.net/reader036/viewer/2022062318/5fd731711b4f6640da3d62dd/html5/thumbnails/90.jpg)
CMU 15-721 (Spring 2017)
PELOTON TEAM MEETING
Wednesdays @ 12:00pm in GHC 9115
Come if you are interested in doing an independent study or capstone project. Free food.
44