Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Advanced Database Systems: Transaction Processing Recovery, Slides of Database Management Systems (DBMS)

The recovery aspect of transaction processing in advanced database systems. It covers topics such as atomicity, consistency, isolation, durability, and concurrency control. The document also explains the execution model, failures, and various approaches to recovery including naive approach, logging, and checkpointing. It provides examples and rules for undo/redo logging and explains the differences between physical and logical logging. The document concludes with a summary of transaction processing and a review of xml.

Typology: Slides

2011/2012

Uploaded on 01/29/2012

arold
arold 🇺🇸

4.7

(24)

376 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Transaction Processing:
Recovery
CPS 216
Advanced Database Systems
2
Announcements (April 28)
Homework #4 due today
Sample solution will be emailed to you by tomorrow
morning
Project demo period: April 28 – May 1
Remember to email me to sign up for a 30-minute slot
Final exam on Monday, May 2, 2-5pm
3 hours—no time pressure!
Open book, open notes
Comprehensive, but with emphasis on the second half of
the course and materials exercised in homework
Solution to sample final available
3
Review
ACID
Atomicity
Consistency
Isolation Concurrency control
Durability Recovery
pf3
pf4
pf5

Partial preview of the text

Download Advanced Database Systems: Transaction Processing Recovery and more Slides Database Management Systems (DBMS) in PDF only on Docsity!

Transaction Processing:

Recovery

CPS 216

Advanced Database Systems

2

Announcements (April 28)

™ Homework #4 due today

ƒ Sample solution will be emailed to you by tomorrow

morning

™ Project demo period: April 28 – May 1

ƒ Remember to email me to sign up for a 30-minute slot

™ Final exam on Monday, May 2, 2-5pm

ƒ 3 hours—no time pressure!

ƒ Open book, open notes

ƒ Comprehensive, but with emphasis on the second half of

the course and materials exercised in homework

™ Solution to sample final available

3

Review

™ ACID

ƒ Atomicity

ƒ Consistency

ƒ Isolation Concurrency control

ƒ Durability Recovery

Execution model

™ Before it can be operated upon, disk-resident data must first

be brought into memory

ƒ input( X ): copy the disk block containing object X to memory ƒ v = read( X ): read the value of X into a local variable v

  • Execute input( X ) first if necessary ƒ write( X , v ): write value v to X in memory
  • Execute input( X ) first if necessary ƒ output( X ): write the memory block containing X to disk

CPU

Memory

Disk X Y…

X Y…

Issued by transactions

Issued by DBMS

5

Failures

™ System crashes in the middle of a transaction T ;

partial effects of T were written to disk

ƒ How do we undo T (atomicity)?

™ System crashes right after a transaction T commits;

not all effects of T were written to disk

ƒ How do we complete T (durability)?

™ Media fails; data on disk corrupted

ƒ How do we reconstruct the database (durability)?

6

Naïve approach

™ Force: When a transaction commits, all writes of this

transaction must be reflected on disk

ƒ Without force, if system crashes right after T commits, effects of T will be lost )Problem:

™ No steal: Writes of a transaction can only be flushed to disk

at commit time

ƒ With steal, if system crashes before T commits but after some writes of T have been flushed to disk, there is no way to undo these writes )Problem:

Checkpointing

™ Naïve approach:

ƒ Stop accepting new transactions (lame!) ƒ Finish all active transactions ƒ Take a database dump ƒ Now safe to truncate the log

™ Fuzzy checkpointing

ƒ Determine S , the set of currently active transactions, and log h begin-checkpoint S i ƒ Flush all modified memory blocks at your leisure ƒ Log h end-checkpoint begin-checkpoint_location i ƒ Between begin and end, continue processing old and new transactions

11

Recovery: analysis and redo phase

™ Need to determine U , the set of active transactions at time

of crash

™ Scan log backward to find the last end-checkpoint record

and follow the pointer to find the corresponding

h start-checkpoint S i

™ Initially, let U be S

™ Scan forward from that start-checkpoint to end of the log

ƒ For a log record h T , start i, add T to U ƒ For a log record h T , commit | abort i, remove T from U ƒ For a log record h T , X , old , new i, issue write( X , new ) )Basically repeats history!

12

Recovery: undo phase

™ Scan log backward

ƒ Undo the effects of transactions in U

ƒ That is, for each log record h T , X , old , new i where T is

in U , issue write( X , old ), and log this operation too (part

of the repeating-history paradigm)

ƒ Log h T , abort i when all effects of T have been undone

) An optimization

ƒ Each log record stores a pointer to the previous log

record for the same transaction; follow the pointer chain

during undo

Physical vs. logical logging

™ Physical logging (what we have assumed so far)

ƒ Log before and after images of data

™ Logical logging

ƒ Log operations (e.g., insert a row into a table) ƒ Smaller log records

  • An insertion could cause rearrangement of things on disk
  • Or trigger hundreds of other events ƒ Sometimes necessary
  • Assume row-level rather than page(block)-level locking
  • Data might have moved to another block at time of undo! ƒ Much harder to make redo/undo idempotent )See solution offered by ARIES

14

ARIES

“ARIES: A Transaction Recovery Method Supporting Fine-Granularity Locking and Partial Rollbacks Using Write-Ahead Logging,” by Mohan et al. TODS 1992

™ Same basic ideas: steal, no force, WAL

™ Three phases: analysis, redo, undo

ƒ Repeats history (redo even incomplete transactions)

™ Better than our simple algorithm

ƒ CLR (Compensation Log Record) for transaction aborts ƒ Redo/undo on an object is only performed when necessary → idempotency requirement lifted → logical logging supported

  • Each disk block records the LSN (log sequence number) of the last change ƒ Can take advantage of a partial checkpoint
  • Recovery can start from any start-checkpoint, not necessarily one that corresponds to an end-checkpoint

15

Summary

™ Concurrency control

ƒ Serial schedule: no interleaving

ƒ Conflict-serializable schedule: no cycles in the precedence

graph; equivalent to a serial schedule

ƒ 2PL: guarantees a conflict-serializable schedule

ƒ Strict 2PL: also guarantees recoverability

™ Recovery: undo/redo logging with fuzzy

checkpointing

ƒ Normal operation: write-ahead logging, no force, steal

ƒ Recovery: first redo (forward), and then undo (backword)