Implementing Durability

COMP9315 21T1 ♢ Implementing Durability ♢ [0/13]
❖ Atomicity/Durability

Reminder:

Transactions are atomic

Transaction effects are durable
Implementation of atomicity/durability is intertwined.
COMP9315 21T1 ♢ Implementing Durability ♢ [1/13]
❖ Durability


What kinds of "system failures" do we need to deal with?

The last requires off-site backup; all others should be locally recoverable.

COMP9315 21T1 ♢ Implementing Durability ♢ [2/13]
❖ Durability (cont)

Consider following scenario:

[Diagram:Pics/txproc/crash.png]

Desired behaviour after system restart:

COMP9315 21T1 ♢ Implementing Durability ♢ [3/13]
❖ Durability (cont)

Durabilty begins with a stable disk storage subsystem


We can prevent/minimise loss/corruption of data due to:
COMP9315 21T1 ♢ Implementing Durability ♢ [4/13]
❖ Dealing with Transactions


The remaining "failure modes" that we need to consider:


Standard technique for managing these:
COMP9315 21T1 ♢ Implementing Durability ♢ [5/13]
❖ Architecture for Atomicity/Durability

How does a DBMS provide for atomicity/durability?


[Diagram:Pics/txproc/arch.png]

COMP9315 21T1 ♢ Implementing Durability ♢ [6/13]
❖ Execution of Transactions

Transactions deal with three address/memory spaces:

Each of these may hold a different "version" of a DB object.


PostgreSQL processes make heavy use of shared buffer pool

⇒ transactions do not deal with much local data.

COMP9315 21T1 ♢ Implementing Durability ♢ [7/13]
❖ Execution of Transactions (cont)

Operations available for data transfer:

READ/WRITE are issued by transaction.

INPUT/OUTPUT are issued by buffer manager (and log manager).

INPUT/OUTPUT correspond to getPage()/putPage() mentioned above

COMP9315 21T1 ♢ Implementing Durability ♢ [8/13]
❖ Execution of Transactions (cont)

Example of transaction execution:

-- implements A = A*2; B = B+1;
BEGIN
READ(A,v); v = v*2; WRITE(A,v);
READ(B,v); v = v+1; WRITE(B,v);
COMMIT

READ accesses the buffer manager and may cause INPUT.

COMMIT needs to ensure that buffer contents go to disk.

COMP9315 21T1 ♢ Implementing Durability ♢ [9/13]
❖ Execution of Transactions (cont)

States as the transaction executes:


t   Action        v  Buf(A)  Buf(B)  Disk(A)  Disk(B)
-----------------------------------------------------
(0) BEGIN         .      .       .        8        5
(1) READ(A,v)     8      8       .        8        5
(2) v = v*2      16      8       .        8        5
(3) WRITE(A,v)   16     16       .        8        5
(4) READ(B,v)     5     16       5        8        5
(5) v = v+1       6     16       5        8        5
(6) WRITE(B,v)    6     16       6        8        5
(7) OUTPUT(A)     6     16       6       16        5
(8) OUTPUT(B)     6     16       6       16        6

After tx completes, we must have either
Disk(A)=8, Disk(B)=5   or   Disk(A)=16, Disk(B)=6

If system crashes before (8), may need to undo disk changes.
If system crashes after (8), may need to redo disk changes.

COMP9315 21T1 ♢ Implementing Durability ♢ [10/13]
❖ Transactions and Buffer Pool

Two issues arise w.r.t. buffers:

Ideally, we want stealing and not forcing.
COMP9315 21T1 ♢ Implementing Durability ♢ [11/13]
❖ Transactions and Buffer Pool (cont)

Handling stealing:

COMP9315 21T1 ♢ Implementing Durability ♢ [12/13]
❖ Transactions and Buffer Pool (cont)

Handling no forcing:


Above scenario may be a problem, even if we are forcing
COMP9315 21T1 ♢ Implementing Durability ♢ [13/13]


Produced: 20 Apr 2021