cmu scs 15-721 :: concurrency control (part iii) · optimistic concurrency control ....

104
Andy Pavlo // Carnegie Mellon University // Spring 2016 Lecture #05 – Concurrency Control Part III DATABASE SYSTEMS 15-721

Upload: others

Post on 18-Oct-2020

20 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

Andy Pavlo // Carnegie Mellon University // Spring 2016

Lecture #05 – Concurrency Control Part III

DATABASE SYSTEMS

15-721

Page 2: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

TODAY ’S AGENDA

Stored Procedures Optimistic Concurrency Control Course Projects

2

Page 3: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

OBSERVATION

Disk stalls are (almost) gone when executing txns in an in-memory DBMS.

There are still other stalls when an app uses conversational API to execute queries on DBMS → ODBC/JDBC → DBMS-specific wire protocols

3

Page 4: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

CONVERSATIONAL DATABASE API

4

Application

BEGIN SQL Program Logic SQL Program Logic ⋮ COMMIT

Page 5: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

CONVERSATIONAL DATABASE API

4

Application

BEGIN SQL Program Logic SQL Program Logic ⋮ COMMIT

Page 6: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

CONVERSATIONAL DATABASE API

4

Application

BEGIN SQL Program Logic SQL Program Logic ⋮ COMMIT

Page 7: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

CONVERSATIONAL DATABASE API

4

Application

BEGIN SQL Program Logic SQL Program Logic ⋮ COMMIT

Parser Planner Optimizer Query Execution

Page 8: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

CONVERSATIONAL DATABASE API

4

Application

BEGIN SQL Program Logic SQL Program Logic ⋮ COMMIT

Parser Planner Optimizer Query Execution

Page 9: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

CONVERSATIONAL DATABASE API

4

Application

BEGIN SQL Program Logic SQL Program Logic ⋮ COMMIT

Parser Planner Optimizer Query Execution

Page 10: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

CONVERSATIONAL DATABASE API

4

Application

BEGIN SQL Program Logic SQL Program Logic ⋮ COMMIT

Parser Planner Optimizer Query Execution

Page 11: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

CONVERSATIONAL DATABASE API

4

Application

BEGIN SQL Program Logic SQL Program Logic ⋮ COMMIT

Parser Planner Optimizer Query Execution

Page 12: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

SOLUTIONS

Prepared Statements → Removes query preparation overhead.

Query Batches → Reduces the number of network roundtrips.

Stored Procedures → Removes both preparation and network stalls.

5

Page 13: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

STORED PROCEDURES

A stored procedure is a group of queries that form a logical unit and perform a particular task on behalf of an application directly inside of the DBMS. Programming languages: → SQL/PSM (standard) → PL/SQL (Oracle / IBM / MySQL) → Transact-SQL (Microsoft)

6

Page 14: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

STORED PROCEDURES

7

Application

BEGIN SQL Program Logic SQL Program Logic ⋮ COMMIT

Page 15: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

STORED PROCEDURES

7

Application PROC(x)

Page 16: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

STORED PROCEDURES

7

Application

CALL PROC(x=99)

PROC(x)

Page 17: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

STORED PROCEDURES

7

Application

CALL PROC(x=99)

PROC(x)

Page 18: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

STORED PROCEDURE EXAMPLE

8

CREATE PROCEDURE testProc (num INT, name VARCHAR) RETURNS INT BEGIN DECLARE cnt INT DEFAULT 0; LOOP INSERT INTO student VALUES (cnt, name); SET cnt := cnt + 1; IF (cnt > 15) THEN RETURN cnt; END IF; END LOOP; END;

Page 19: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

ADVANTAGES

Reduce the number of round trips between application and database servers.

Increased performance because queris are pre-compiled and stored in DBMS.

Procedure reuse across applications.

9

Page 20: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

DISADVANTAGES

Not as many developers know how to write SQL/PSM code. → Safe Languages vs. Sandbox Languages

Outside the scope of the application so it is difficult to manage versions and hard to debug.

Probably not be portable to other DBMSs.

10

Page 21: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

DISADVANTAGES

Not as many developers know how to write SQL/PSM code. → Safe Languages vs. Sandbox Languages

Outside the scope of the application so it is difficult to manage versions and hard to debug.

Probably not be portable to other DBMSs.

10

Page 22: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

OPTIMISTIC CONCURRENCY CONTROL

Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not visible to other active txns. When a txn commits, the DBMS verifies that there are no conflicts. First proposed in 1981 at CMU by H.T. Kung.

11

Page 23: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

OPTIMISTIC CONCURRENCY CONTROL

12

Txn #1

BEGIN

READ(A) WRITE(A) WRITE(B) COMMIT

Page 24: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

OPTIMISTIC CONCURRENCY CONTROL

12

Txn #1

BEGIN

READ(A) WRITE(A) WRITE(B)

Record Value Write Timestamp

B 456 10000

123 A 10000

COMMIT

Page 25: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

OPTIMISTIC CONCURRENCY CONTROL

12

Txn #1

BEGIN

READ(A) WRITE(A) WRITE(B)

Record Value Write Timestamp

B 456 10000

123 A 10000

COMMIT

Page 26: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

OPTIMISTIC CONCURRENCY CONTROL

12

Txn #1

BEGIN

READ(A) WRITE(A) WRITE(B)

Read Phase Record Value Write

Timestamp

B 456 10000

123 A 10000

COMMIT

Page 27: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

OPTIMISTIC CONCURRENCY CONTROL

12

Txn #1

BEGIN

READ(A) WRITE(A) WRITE(B)

Record Value Write Timestamp

B 456 10000

123 A 10000

COMMIT

Page 28: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

OPTIMISTIC CONCURRENCY CONTROL

12

Txn #1

BEGIN

READ(A) WRITE(A) WRITE(B)

Record Value Write Timestamp

B 456 10000

123 A 10000

COMMIT

Page 29: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

OPTIMISTIC CONCURRENCY CONTROL

12

Txn #1

BEGIN

READ(A) WRITE(A) WRITE(B)

Workspace

Record Value Write Timestamp Record Value Write

Timestamp

B 456 10000

123 A 10000

COMMIT

Page 30: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

OPTIMISTIC CONCURRENCY CONTROL

12

Txn #1

BEGIN

READ(A) WRITE(A) WRITE(B)

Workspace

Record Value Write Timestamp

123 A 10000

Record Value Write Timestamp

B 456 10000

123 A 10000

COMMIT

Page 31: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

OPTIMISTIC CONCURRENCY CONTROL

12

Txn #1

BEGIN

READ(A) WRITE(A) WRITE(B)

Workspace

Record Value Write Timestamp

123 A 10000

Record Value Write Timestamp

B 456 10000

123 A 10000

COMMIT

Page 32: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

OPTIMISTIC CONCURRENCY CONTROL

12

Txn #1

BEGIN

READ(A) WRITE(A) WRITE(B)

Workspace

Record Value Write Timestamp

123 A 10000

Record Value Write Timestamp

B 456 10000

123 A 10000

COMMIT

Page 33: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

OPTIMISTIC CONCURRENCY CONTROL

12

Txn #1

BEGIN

READ(A) WRITE(A) WRITE(B)

Workspace

Record Value Write Timestamp

123 A 10000

Record Value Write Timestamp

B 456 10000

123 A 10000 888 ∞ COMMIT

Page 34: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

OPTIMISTIC CONCURRENCY CONTROL

12

Txn #1

BEGIN

READ(A) WRITE(A) WRITE(B)

Workspace

Record Value Write Timestamp

123 A 10000

Record Value Write Timestamp

B 456 10000

123 A 10000 888 ∞ COMMIT

Page 35: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

OPTIMISTIC CONCURRENCY CONTROL

12

Txn #1

BEGIN

READ(A) WRITE(A) WRITE(B)

Workspace

Record Value Write Timestamp

B 456 10000

123 A 10000

Record Value Write Timestamp

B 456 10000

123 A 10000 888 ∞ COMMIT

Page 36: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

OPTIMISTIC CONCURRENCY CONTROL

12

Txn #1

BEGIN

READ(A) WRITE(A) WRITE(B)

Workspace

Record Value Write Timestamp

B 456 10000

123 A 10000

Record Value Write Timestamp

B 456 10000

123 A 10000 888 ∞ 999 ∞

COMMIT

Page 37: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

OPTIMISTIC CONCURRENCY CONTROL

12

Txn #1

BEGIN

READ(A) WRITE(A) WRITE(B)

Workspace

Record Value Write Timestamp

B 456 10000

123 A 10000

Record Value Write Timestamp

B 456 10000

123 A 10000 888 ∞ 999 ∞

COMMIT

Page 38: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

OPTIMISTIC CONCURRENCY CONTROL

12

Txn #1

BEGIN

READ(A) WRITE(A) WRITE(B) VALIDATE PHASE WRITE PHASE

Workspace

Record Value Write Timestamp

B 456 10000

123 A 10000

Record Value Write Timestamp

B 456 10000

123 A 10000 888 ∞ 999 ∞

COMMIT

Page 39: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

OPTIMISTIC CONCURRENCY CONTROL

12

Txn #1

BEGIN

READ(A) WRITE(A) WRITE(B) VALIDATE PHASE WRITE PHASE

Workspace

Record Value Write Timestamp

B 456 10000

123 A 10000

Record Value Write Timestamp

B 456 10000

123 A 10000 888 ∞ 999 ∞

COMMIT

Page 40: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

OPTIMISTIC CONCURRENCY CONTROL

12

Txn #1

BEGIN

READ(A) WRITE(A) WRITE(B) VALIDATE PHASE WRITE PHASE

Workspace

Record Value Write Timestamp

B 456 10000

123 A 10000

Record Value Write Timestamp

B 456 10000

123 A 10000 888 ∞ 999 ∞

COMMIT

Page 41: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

OPTIMISTIC CONCURRENCY CONTROL

12

Txn #1

BEGIN

READ(A) WRITE(A) WRITE(B) VALIDATE PHASE WRITE PHASE

10001

Workspace

Record Value Write Timestamp

B 456 10000

123 A 10000

Record Value Write Timestamp

B 456 10000

123 A 10000 888 ∞ 999 ∞

COMMIT

Page 42: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

OPTIMISTIC CONCURRENCY CONTROL

12

Txn #1

BEGIN

READ(A) WRITE(A) WRITE(B) VALIDATE PHASE WRITE PHASE

10001

Workspace

Record Value Write Timestamp

B 456 10000

123 A 10000

Record Value Write Timestamp

B 456 10000

123 A 10000 888 ∞ 999 ∞

COMMIT

888

999 10001

10001

Page 43: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

OPTIMISTIC CONCURRENCY CONTROL

12

Txn #1

BEGIN

READ(A) WRITE(A) WRITE(B) VALIDATE PHASE WRITE PHASE

10001

Record Value Write Timestamp

B 456 10000

123 A 10000

COMMIT

888

999 10001

10001

Page 44: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

READ PHASE

Track the read/write sets of txns and store their writes in a private workspace. The DBMS copies every tuple that the txn accesses from the shared database to its workspace ensure repeatable reads.

13

Page 45: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

VALIDATION PHASE

When the txn invokes COMMIT, the DBMS checks if it conflicts with other txns.

Two methods for this phase: → Backward Validation → Forward Validation

14

Page 46: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

BACKWARD VALIDATION

Check whether the committing txn intersects its read/write sets with those of any txns that have already committed.

15

Txn #1

Txn #2

Txn #3

TIME

COMM

IT

COMM

IT

COMM

IT

Page 47: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

BACKWARD VALIDATION

Check whether the committing txn intersects its read/write sets with those of any txns that have already committed.

15

Txn #1

Txn #2

Txn #3

TIME

COMM

IT

COMM

IT

COMM

IT

Page 48: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

BACKWARD VALIDATION

Check whether the committing txn intersects its read/write sets with those of any txns that have already committed.

15

Txn #1

Txn #2

Txn #3

TIME

COMM

IT

COMM

IT

COMM

IT

Page 49: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

BACKWARD VALIDATION

Check whether the committing txn intersects its read/write sets with those of any txns that have already committed.

15

Txn #1

Txn #2

Txn #3

TIME

COMM

IT

COMM

IT

COMM

IT

Page 50: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

BACKWARD VALIDATION

Check whether the committing txn intersects its read/write sets with those of any txns that have already committed.

15

Txn #1

Txn #2

Txn #3

TIME

COMM

IT

COMM

IT

COMM

IT

Validation Scope

Page 51: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

FORWARD VALIDATION

Check whether the committing txn intersects its read/write sets with any active txns that have not yet committed.

16

Txn #1

Txn #2

Txn #3

TIME

COMM

IT

COMM

IT

COMM

IT

Page 52: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

FORWARD VALIDATION

Check whether the committing txn intersects its read/write sets with any active txns that have not yet committed.

16

Txn #1

Txn #2

Txn #3

TIME

COMM

IT

COMM

IT

COMM

IT

Page 53: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

FORWARD VALIDATION

Check whether the committing txn intersects its read/write sets with any active txns that have not yet committed.

16

Txn #1

Txn #2

Txn #3

TIME

COMM

IT

COMM

IT

COMM

IT

Validation Scope

Page 54: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

VALIDATION PHASE

Original OCC uses serial validation. Parallel validation means that each txn must check the read/write sets of other txns that are trying to validate at the same time. → Each txn has to acquire locks for its write set records

in some global order. → The txn does not need locks for read set records.

17

Page 55: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

WRITE PHASE

The DBMS propagates the changes in the txn’s write set to the database and makes them visible to other txns. As each record is updated, the txn releases the lock acquired during the Validation Phase.

18

Page 56: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

MODERN OCC

Harvard/MIT Silo MIT/CMU TicToc

19

Page 57: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

SILO

Single-node, in-memory OLTP DBMS. → Serializable OCC with parallel backward validation. → Stored procedure-only API.

No writes to shared-memory for read txns. Batched timestamp allocation using epochs. Pure awesomeness from Eddie Kohler.

20

SPEEDY TRANSACTIONS IN MULTICORE IN-MEMORY DATABASES SOSP 2013

Page 58: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

SILO: EPOCHS

Time is sliced into fixed-length epochs (40ms). All txns that start in the same epoch will be committed together at the end of the epoch. → Txns that span an epoch have to refresh themselves

to be carried over into the next epoch.

Worker threads only need to synchronize at the beginning of each epoch.

21

Page 59: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

SILO: TRANSACTION IDS

Each worker thread generates a unique txn id based on the current epoch number and the next value in its assigned batch.

22

Worker Worker

Worker Worker

Epoch Thread

Page 60: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

SILO: TRANSACTION IDS

Each worker thread generates a unique txn id based on the current epoch number and the next value in its assigned batch.

22

Worker Worker

Worker Worker

Epoch Thread

Epoch=100

Page 61: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

SILO: TRANSACTION IDS

Each worker thread generates a unique txn id based on the current epoch number and the next value in its assigned batch.

22

Worker Worker

Worker Worker

Epoch Thread

Epoch=100 [0,10]

[11,20] [31,40]

[21,30]

Page 62: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

SILO: TRANSACTION IDS

Each worker thread generates a unique txn id based on the current epoch number and the next value in its assigned batch.

22

Worker Worker

Worker Worker

Epoch Thread

[0,10]

[11,20] [31,40]

[21,30] Epoch=200

Page 63: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

SILO: COMMIT PROTOCOL

23

POINTER ATTR1 ATTR2

#-###-# ¤ John $100

#-###-# ¤ Tupac $999

#-###-# ¤ Wiz $67

#-###-# ¤ O.D.B. $13

TID Word

Page 64: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

SILO: COMMIT PROTOCOL

23

POINTER ATTR1 ATTR2

#-###-# ¤ John $100

#-###-# ¤ Tupac $999

#-###-# ¤ Wiz $67

#-###-# ¤ O.D.B. $13

BATCH TIMESTAMP EPOCH LOCKS

TID Word

Page 65: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

SILO: COMMIT PROTOCOL

23

POINTER ATTR1 ATTR2

#-###-# ¤ John $100

#-###-# ¤ Tupac $999

#-###-# ¤ Wiz $67

#-###-# ¤ O.D.B. $13

TID Word

Page 66: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

SILO: COMMIT PROTOCOL

23

POINTER ATTR1 ATTR2

#-###-# ¤ John $100

#-###-# ¤ Tupac $999

#-###-# ¤ Wiz $67

#-###-# ¤ O.D.B. $13

Workspace Read Set

Write Set

#-###-# O.D.B. $13

Tupac $777

#-###-# Tupac $999

TID Word

Page 67: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

SILO: COMMIT PROTOCOL

23

POINTER ATTR1 ATTR2

#-###-# ¤ John $100

#-###-# ¤ Tupac $999

#-###-# ¤ Wiz $67

#-###-# ¤ O.D.B. $13

Step #1: Lock Write Set

Workspace Read Set

Write Set

#-###-# O.D.B. $13

Tupac $777

#-###-# Tupac $999

TID Word

Page 68: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

SILO: COMMIT PROTOCOL

23

POINTER ATTR1 ATTR2

#-###-# ¤ John $100

#-###-# ¤ Tupac $999

#-###-# ¤ Wiz $67

#-###-# ¤ O.D.B. $13

Step #1: Lock Write Set

Workspace Read Set

Write Set

#-###-# O.D.B. $13

Tupac $777

#-###-# Tupac $999

TID Word

Page 69: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

SILO: COMMIT PROTOCOL

23

POINTER ATTR1 ATTR2

#-###-# ¤ John $100

#-###-# ¤ Tupac $999

#-###-# ¤ Wiz $67

#-###-# ¤ O.D.B. $13

Step #1: Lock Write Set

Workspace Read Set

Write Set

#-###-# O.D.B. $13

Tupac $777

#-###-# Tupac $999

Step #2: Examine Read Set

TID Word

Page 70: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

SILO: COMMIT PROTOCOL

23

POINTER ATTR1 ATTR2

#-###-# ¤ John $100

#-###-# ¤ Tupac $999

#-###-# ¤ Wiz $67

#-###-# ¤ O.D.B. $13

Step #1: Lock Write Set

Workspace Read Set

Write Set

#-###-# O.D.B. $13

Tupac $777

#-###-# Tupac $999

Step #2: Examine Read Set

TID Word

Page 71: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

SILO: COMMIT PROTOCOL

23

POINTER ATTR1 ATTR2

#-###-# ¤ John $100

#-###-# ¤ Tupac $999

#-###-# ¤ Wiz $67

#-###-# ¤ O.D.B. $13

Step #1: Lock Write Set

Workspace Read Set

Write Set

#-###-# O.D.B. $13

Tupac $777

#-###-# Tupac $999

Step #2: Examine Read Set

???

TID Word

Page 72: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

SILO: COMMIT PROTOCOL

23

POINTER ATTR1 ATTR2

#-###-# ¤ John $100

#-###-# ¤ Tupac $999

#-###-# ¤ Wiz $67

#-###-# ¤ O.D.B. $13

Step #1: Lock Write Set

Workspace Read Set

Write Set

#-###-# O.D.B. $13

Tupac $777

#-###-# Tupac $999

Step #2: Examine Read Set

???

TID Word

Page 73: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

SILO: COMMIT PROTOCOL

23

POINTER ATTR1 ATTR2

#-###-# ¤ John $100

#-###-# ¤ Tupac $999

#-###-# ¤ Wiz $67

#-###-# ¤ O.D.B. $13

Step #1: Lock Write Set

Workspace Read Set

Write Set

#-###-# O.D.B. $13

Tupac $777

#-###-# Tupac $999

Step #2: Examine Read Set

TID Word

Page 74: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

SILO: COMMIT PROTOCOL

23

POINTER ATTR1 ATTR2

#-###-# ¤ John $100

#-###-# ¤ Tupac $999

#-###-# ¤ Wiz $67

#-###-# ¤ O.D.B. $13

Step #1: Lock Write Set

Workspace Read Set

Write Set

#-###-# O.D.B. $13

Tupac $777

#-###-# Tupac $999

Step #2: Examine Read Set

TID Word

Page 75: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

SILO: COMMIT PROTOCOL

23

POINTER ATTR1 ATTR2

#-###-# ¤ John $100

#-###-# ¤ Tupac $999

#-###-# ¤ Wiz $67

#-###-# ¤ O.D.B. $13

Step #1: Lock Write Set

Workspace Read Set

Write Set

#-###-# O.D.B. $13

Tupac $777

#-###-# Tupac $999

Step #2: Examine Read Set

TID Word

Page 76: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

SILO: COMMIT PROTOCOL

23

POINTER ATTR1 ATTR2

#-###-# ¤ John $100

#-###-# ¤ Tupac $999

#-###-# ¤ Wiz $67

#-###-# ¤ O.D.B. $13

Step #1: Lock Write Set

Workspace Read Set

Write Set

#-###-# O.D.B. $13

Tupac $777

#-###-# Tupac $999

Step #2: Examine Read Set Step #3: Install Write Set

TID Word

Page 77: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

SILO: COMMIT PROTOCOL

23

POINTER ATTR1 ATTR2

#-###-# ¤ John $100

#-###-# ¤ Tupac $999

#-###-# ¤ Wiz $67

#-###-# ¤ O.D.B. $13

Step #1: Lock Write Set

Workspace Read Set

Write Set

#-###-# O.D.B. $13

Tupac $777

#-###-# Tupac $999

Step #2: Examine Read Set Step #3: Install Write Set

TID Word

$777 #-###-#

Page 78: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

SILO: GARBAGE COLLECTION

Cooperative threads GC. Each worker thread marks a deleted object with a reclamation epoch. → This is the epoch after which no thread could access

the object again, and thus can be safely removed. → Object references are maintained in thread-local

storage to avoid unnecessary data movement.

24

Page 79: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

SILO: RANGE QUERIES

DBMS handles phantoms by tracking the txn’s scan set (node set) on indexes. → Have to include “virtual” entries for keys that do not

exist in the index. → This is the same technique used in Hekaton.

We will discuss key-range and index gap locking next class…

25

Page 80: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

SILO: PERFORMANCE

26

Source: Eddie Kohler

Database: TPC-C with 28 Warehouses Processor: 4 sockets, 8 cores per socket

Page 81: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

SILO: PERFORMANCE

26

Source: Eddie Kohler

Database: TPC-C with 28 Warehouses Processor: 4 sockets, 8 cores per socket

Page 82: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

TICTOC

Serializable OCC implemented in DBx1000. → Parallel backward validation → Stored procedure-only API

No global timestamp allocation. Txn timestamps are derived from records.

27

TICTOC: TIME-TRAVELING OPTIMISTIC CONCURRENCY CONTROL SIGMOD 2016

Page 83: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

TICTOC: RECORD TIMESTAMPS

Write Timestamp (W-TS): → The logical timestamp of the last committed txn that

wrote to the record.

Read Timestamp (R-TS): → The logical timestamp of the last txn that read the

record.

A record is considered valid from W-TS to R-TS

28

Page 84: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

Txn

TICTOC: VALIDATION PHASE

29

READ(B)

WRITE(A)

READ(C)

1 2 3 4 LOGICAL TIME

Page 85: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

Txn

TICTOC: VALIDATION PHASE

29

READ(B)

WRITE(A)

READ(C)

1 2 3 4 LOGICAL TIME

A

B

C

Page 86: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

Txn

TICTOC: VALIDATION PHASE

29

READ(B)

WRITE(A)

READ(C)

1 2 3 4 LOGICAL TIME

W-TS R-TS

A

B

C

Page 87: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

Txn

TICTOC: VALIDATION PHASE

29

READ(B)

WRITE(A)

READ(C)

1 2 3 4 LOGICAL TIME

Page 88: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

Txn

TICTOC: VALIDATION PHASE

29

READ(B)

WRITE(A)

READ(C)

1 2 3 4 LOGICAL TIME

Step #1: Lock Write Set

Page 89: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

Txn

TICTOC: VALIDATION PHASE

29

READ(B)

WRITE(A)

READ(C)

1 2 3 4 LOGICAL TIME

Step #1: Lock Write Set Step #2: Compute CommitTS

Page 90: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

Txn

TICTOC: VALIDATION PHASE

29

READ(B)

WRITE(A)

READ(C)

1 2 3 4 LOGICAL TIME

Step #1: Lock Write Set Step #2: Compute CommitTS

CommitTS

Page 91: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

Txn

TICTOC: VALIDATION PHASE

29

READ(B)

WRITE(A)

READ(C)

1 2 3 4 LOGICAL TIME

Step #1: Lock Write Set Step #2: Compute CommitTS Step #3: Validate Read Set

CommitTS

Page 92: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

Txn

TICTOC: VALIDATION PHASE

29

READ(B)

WRITE(A)

READ(C)

1 2 3 4 LOGICAL TIME

Step #1: Lock Write Set Step #2: Compute CommitTS Step #3: Validate Read Set

CommitTS

Page 93: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

Txn

TICTOC: VALIDATION PHASE

29

READ(B)

WRITE(A)

READ(C)

1 2 3 4 LOGICAL TIME

Step #1: Lock Write Set Step #2: Compute CommitTS Step #3: Validate Read Set

CommitTS

Page 94: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

Txn

TICTOC: VALIDATION PHASE

29

READ(B)

WRITE(A)

READ(C)

1 2 3 4 LOGICAL TIME

Step #1: Lock Write Set Step #2: Compute CommitTS Step #3: Validate Read Set

CommitTS

???

Page 95: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

Txn

TICTOC: VALIDATION PHASE

29

READ(B)

WRITE(A)

READ(C)

1 2 3 4 LOGICAL TIME

Step #1: Lock Write Set Step #2: Compute CommitTS Step #3: Validate Read Set

CommitTS

Page 96: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

Txn

TICTOC: VALIDATION PHASE

29

READ(B)

WRITE(A)

READ(C)

1 2 3 4 LOGICAL TIME

Step #1: Lock Write Set Step #2: Compute CommitTS Step #3: Validate Read Set

Case 1: Latest Version

CommitTS

Page 97: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

Txn

TICTOC: VALIDATION PHASE

29

READ(B)

WRITE(A)

READ(C)

1 2 3 4 LOGICAL TIME

Step #1: Lock Write Set Step #2: Compute CommitTS Step #3: Validate Read Set

Case 1: Latest Version Case 2: Updated Before CommitTS

CommitTS

Page 98: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

Txn

TICTOC: VALIDATION PHASE

29

READ(B)

WRITE(A)

READ(C)

1 2 3 4 LOGICAL TIME

Step #1: Lock Write Set Step #2: Compute CommitTS Step #3: Validate Read Set

Case 1: Latest Version Case 2: Updated Before CommitTS

CommitTS

Page 99: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

Txn

TICTOC: VALIDATION PHASE

29

READ(B)

WRITE(A)

READ(C)

1 2 3 4 LOGICAL TIME

Step #1: Lock Write Set Step #2: Compute CommitTS Step #3: Validate Read Set

Case 1: Latest Version Case 2: Updated Before CommitTS Case 3: Updated After CommitTS

CommitTS

Page 100: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

TICTOC: PERFORMANCE

30

0.0

1.0

2.0

3.0

0 10 20 30 40

Thro

ughp

ut (t

xn/s

ec)

Thread Count

TICTOC HEKATON DL_DETECT NO_WAIT SILOmillions

Database: 10GB YCSB Processor: 4 sockets, 10 cores per socket

Medium Contention 90% Reads / 10% Writes

Page 101: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

TICTOC: PERFORMANCE

30

0.0

1.0

2.0

3.0

0 10 20 30 40

Thro

ughp

ut (t

xn/s

ec)

Thread Count

0.0

0.2

0.4

0.6

0.8

1.0

0 10 20 30 40Thro

ughp

ut (t

xn/s

ec)

Thread Count

TICTOC HEKATON DL_DETECT NO_WAIT SILOmillions millions

Database: 10GB YCSB Processor: 4 sockets, 10 cores per socket

Medium Contention 90% Reads / 10% Writes

High Contention 50% Reads / 50% Writes

Page 102: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

PARTING THOUGHTS

OCC and MVCC are more or less equivalent → The difference is in when to check for conflicts and

where to store in-flight data for active txns.

Trade-off between aborting txns early or later. → Early: Avoid wasted work for txns that will

eventually abort, but has checking overhead. → Later: No runtime overhead but lots of wasted work

under high contention.

31

Page 103: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

COURSE PROJECTS

Reminder: Project #1 is due Feb 8th @ 11:59pm We will get Autolab working this weekend. See project specification for how to do proper debugging and logging. I will post a form to sign up for project groups.

32

Page 104: CMU SCS 15-721 :: Concurrency Control (Part III) · OPTIMISTIC CONCURRENCY CONTROL . Timestamp-ordering scheme where txns copy data read/write into a private workspace that is not

CMU 15-721 (Spring 2016)

NEXT CLASS

Index Locking

33