Docsity

Software Concepts and Techniques for E Commerce | CS 8803, Study notes of Computer Science

Toggle sidebar
bg1
1
CS8803-I Software Concepts and
Techniques for E-Commerce
Calton Pu
College of Computing
3B: Crash Recovery
3B: Crash Recovery
2
A Simplistic TP System
A Simplistic TP System
zUse 2PL for concurrency control
zWrite updates to database as they happen
zProblems with recovery
¾Need to undo the aborted transaction operations
¾What if the system crashes between the
decision to commit, and the writing of last
updates?
¾Need to redo the committed, but unfinished
operations
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Software Concepts and Techniques for E Commerce | CS 8803 and more Study notes Computer Science in PDF only on Docsity!

1

CS8803-I Software Concepts and

Techniques for E-Commerce

Calton Pu

College of Computing

3B: Crash Recovery3B: Crash Recovery

A Simplistic TP System A Simplistic TP System

z Use 2PL for concurrency control

z Write updates to database as they happen

z Problems with recovery

¾ Need to undo the aborted transaction operations ¾ What if the system crashes between the decision to commit, and the writing of last updates? ¾ Need to redo the committed, but unfinished operations

3

Fault Tolerance Basics Fault Tolerance Basics

z Failure mode analysis

¾ Machine crash, transaction abort, media failure

z Machine crash

¾ Disk writes are NOT atomic ¾ The Idea: force write the information to disk before making any changes (to support redo)

z Transaction abort

¾ Programmer may want to abort voluntarily ¾ Use the written information to undo

WriteWrite--Ahead LoggingAhead Logging

z Intentions List

¾ Lampson and Sturgis (1976, unpublished) ¾ Put all writes on stable storage intentions list ¾ If abort, forget the list ¾ Execute the update operations at commit ¾ If crash, re-execute the whole list ¾ Write operations are idempotent ¾ Re-execution repeats until successful completion ¾ Then erase the intentions list

7

Log Insert Log Insert

z Program Outline

¾ Acquire the log lock, find file page ¾ Fill in log record, update the anchor

z LogMgr Daemon

¾ Keeps the log file open ¾ Encapsulates the actual I/O operations

z Log Flush Daemon

¾ Flush requests ¾ Periodic timer interrupts

Careful Write Careful Write

z Serial write

¾ Write one copy of the log ¾ When complete, write other copy

z Ping-Pong

¾ Write page i, and then page i+ ¾ When page full, switch to new page ¾ Parallel writing of both log files

z Sometimes, replicated logs

9

Performance Optimizations Performance Optimizations

z Logging is a bottleneck

¾ Disk I/O is slow compared to CPU ¾ Sequential logging is faster than random write ¾ Steal and no force (next slide)

z Group commit

¾ Amortize commit log flush ¾ Delay transaction commit until full use of log page ¾ Batch only when there is high traffic

10

Buffering Pages Buffering Pages

z Stealing pages before commit

¾ Push pages to disk optimistically ¾ If commit, you win ¾ If abort, need to undo the aborted value

z Forcing pages at commit time

¾ Push pages to disk at commit time ¾ No force: leave pages in memory ¾ Push pages only when convenient ¾ If system crashes, must redo the committed value

13

Restart Using Log Restart Using Log

z Find the Anchor

¾ According to the writing method

z Find Log End

¾ According to the writing method ¾ Sweep through good pages ¾ Stop when bad pages appear

Restart Logic Restart Logic

z Program Outline

¾ Reconstruct log anchor ¾ Undo/Redo pending transactions ¾ Restart log daemons ¾ Start TP processing

z It’s possible to start TP processing early

¾ Need to isolate the restart in a transaction ¾ Start normal transactions at restart lock point (when the restart is guaranteed to succeed)

15

Transaction Manager Transaction Manager

z Basic Functions

¾ Recovery glue for centralized TP ¾ Coordinator for distributed transaction commit ¾ Coordinates distributed recovery

z Application Interface

¾ Begin-T, Commit-T, Abort-T ¾ Savepoint, Rollback ¾ Prepare-T [for 2PC] ¾ Chain-T [for chained] ¾ Leave-T and Resume-T [for nested]

TP System Restart TP System Restart

z TP monitor restarts

¾ LogMgr, LockMgr, TM, and RMs

z TM Restart

¾ REDO committed transactions ¾ Find checkpoint record ¾ Start ResourceMgr restart ¾ Coordinate the end of all involved RMs

19

Disaster Recovery (cont’d) Disaster Recovery (cont’d)

z Symmetric arrangement

¾ Each node is primary for something, and backup for some other node. ¾ If good partitioning cannot be found, then symmetric is worse than single

z Important in practice

¾ For DBMS to take market share, system administrative utilities must be in place

Summary of Lecture (11/27) Summary of Lecture (11/27)

z Recovery basics

¾ Do, Redo, Undo ¾ Write-ahead logging ¾ Transaction abort

z System crash and recovery

¾ Restart