Optimistic Concurrency Control

COMP9315 21T1 ♢ Optimistic CC ♢ [0/8]
❖ Optimistic Concurrency Control

Locking is a pessimistic approach to concurrency control:

Costs: lock management, deadlock handling, contention.

In scenarios where there are far more reads than writes ...

Optimistic concurrency control (OCC) is a strategy to realise this.
COMP9315 21T1 ♢ Optimistic CC ♢ [1/8]
❖ Optimistic Concurrency Control (cont)

Under OCC, transactions have three distinct phases:

Timestamps are recorded at points S, V, F :

[Diagram:Pics/txproc/occ-phases.png]

COMP9315 21T1 ♢ Optimistic CC ♢ [2/8]
❖ Validation

Data structures needed for validation:

Use the V  timestamps as ordering for transactions
COMP9315 21T1 ♢ Optimistic CC ♢ [3/8]
❖ Validation (cont)

Two-transaction example:

Case 0: serial execution ... no problem

[Diagram:Pics/txproc/occ0.png]

COMP9315 21T1 ♢ Optimistic CC ♢ [4/8]
❖ Validation (cont)

Case 1: reading overlaps validation/writing

[Diagram:Pics/txproc/occ1.png]

COMP9315 21T1 ♢ Optimistic CC ♢ [5/8]
❖ Validation (cont)

Case 2: reading/validation overlaps validation/writing

[Diagram:Pics/txproc/occ2.png]

COMP9315 21T1 ♢ Optimistic CC ♢ [6/8]
❖ Validation Check

Validation check for transaction T

If this check fails for any Ti, then T  is rolled back.
COMP9315 21T1 ♢ Optimistic CC ♢ [7/8]
❖ Validation Check (cont)

OCC prevents: T  reading dirty data, T  overwriting Ti's changes

Problems with OCC:

** "Roll back" is relatively cheap
COMP9315 21T1 ♢ Optimistic CC ♢ [8/8]


Produced: 15 Apr 2021