DBMS Transactions and Rollback Recovery Helia / Martti Laiho.

8
DBMS Transactions and Rollback Recovery Helia / Martti Laiho

Transcript of DBMS Transactions and Rollback Recovery Helia / Martti Laiho.

Page 1: DBMS Transactions and Rollback Recovery Helia / Martti Laiho.

DBMS Transactions and

Rollback Recovery

Helia / Martti Laiho

Page 2: DBMS Transactions and Rollback Recovery Helia / Martti Laiho.

Control Buffers

Data Buffer (Buffer pool)

Log Buffer

Transaction Log files

- Connections- Transaction queueing- Locking List- etc

before image / after image

Table pagesand index pages x

Database Instance

Checkpoint:

Commit/Rollback:

Application programs - Sessions (connections) - Transactions - SQL commands

Helia / Martti Laiho, 1998-2003

DBMSListener / ServerTransaction ManagerSQL Engine (parser)Security ManagerQuery OptimizerConcurrency Manager (Lock Manager)Recovery ManagerRelational EngineMemory Manager

DBMSListener / ServerTransaction ManagerSQL Engine (parser)Security ManagerQuery OptimizerConcurrency Manager (Lock Manager)Recovery ManagerRelational EngineMemory Manager

LRU

x

Data file

Data fileFile ManagerFile Manager

Disk ManagerDisk Manager

read

write

write

Page 3: DBMS Transactions and Rollback Recovery Helia / Martti Laiho.

Processing a Transaction

Insert into table

Update table

Delete from table

Select ..

Commit / Rollback

undo /redo data

undo / redo data

undo / redo data

commit / rollback

LGWR

OK ?

continue

User process: Data buffer Redo log buffer

Redo log files

(Rollback Segments -

Oracle only)

undo

undo data

undo data

?

On Rollback

before imagesafter images

Page 4: DBMS Transactions and Rollback Recovery Helia / Martti Laiho.

Marking Checkpoint into Transaction Log

time

T1

T2

T3

T4

T5

Write Checkpointrecord into the log

of the current transactions

tc

Helia / Martti Laiho, 1998-2005

Commit

Rollback

Commit

Begin

Begin

Begin

Begin

Begin

Write all after imagesInto the database

Page 5: DBMS Transactions and Rollback Recovery Helia / Martti Laiho.

A Soft Crash

time

T1

T2

T3

T4

T5

Checkpointrecord

SystemFailure

tctf

“Soft Crash”

Helia / Martti Laiho, 1998-2005

Commit

Rollback

Commit

Page 6: DBMS Transactions and Rollback Recovery Helia / Martti Laiho.

Rollback recovery using transaction log

time

T1

T2

T3

T4

T5

Checkpointrecord

tctf

Rollback Recovery:

Undo list: T1, T2, T3 , T4, T5

Redo list: -

Helia / Martti Laiho, 1998-2005

Commit

Rollback

Commit

2. Find the last checkpoint record

3. Add transactions on undo list

1. Start up

From checkpointrecord

From the log after the checkpoint

Page 7: DBMS Transactions and Rollback Recovery Helia / Martti Laiho.

Rollback recovery using transaction log

time

T1

T2

T3

T4

T5

Checkpointrecord

tctf

Rollback Recovery

Undo list: T1, T2, T3, T4, T5

Redo list: T1, T4

Helia / Martti Laiho, 1998-2005

Commit

Rollback

Commit

34. Move committed transactions to Redo list

Page 8: DBMS Transactions and Rollback Recovery Helia / Martti Laiho.

Rollback recovery using transaction log

time

T1

T2

T3

T4

T5

Checkpointrecord

tc tf

Helia / Martti Laiho, 1998-2005

Commit

Rollback

Commit

Rollback Recovery

Undo list: T1, T2, T3, T4, T5

Redo list: T1, T4

5 5. Rollback transactions of the Undo list - writing the before images into the database Redo transactions of the Redo list - writing the after images into the database

6. Open the DBMS service to applications

undo

redo

redo

undo

undo