SlideShare a Scribd company logo
Fundamentals of Database Systems
Seventh Edition
Chapter 22
Database Recovery
Techniques
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
Introduction
• Recovery algorithms
• Recovery concepts
– Write-ahead logging
– In-place versus shadow updates
– Rollback
– Deferred update
– Immediate update
• Certain recovery techniques best used with specific
concurrency control methods
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
22.1 Recovery Concepts (1 of 9)
• Recovery process restores database to most recent
consistent state before time of failure
• Information kept in system log
• Typical recovery strategies
– Restore backed-up copy of database
▪Best in cases of extensive damage
– Identify any changes that may cause inconsistency
▪Best in cases of noncatastrophic failure
▪Some operations may require redo
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
Recovery Concepts (2 of 9)
• Deferred update techniques
– Do not physically update the database until after
transaction commits
– Undo is not needed; redo may be needed
• Immediate update techniques
– Database may be updated by some operations of a
transaction before it reaches commit point
– Operations also recorded in log
– Recovery still possible
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
Recovery Concepts (3 of 9)
• Undo and redo operations required to be idempotent
– Executing operations multiple times equivalent to
executing just once
– Entire recovery process should be idempotent
• Caching (buffering) of disk blocks
– DBMS cache: a collection of in-memory buffers
– Cache directory keeps track of which database items
are in the buffers
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
Recovery Concepts (4 of 9)
• Cache buffers replaced (flushed) to make space for new
items
• Dirty bit associated with each buffer in the cache
– Indicates whether the buffer has been modified
• Contents written back to disk before flush if dirty bit
equals one
• Pin-unpin bit
– Page is pinned if it cannot be written back to disk yet
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
Recovery Concepts (5 of 9)
• Main strategies
– In-place updating
▪Writes the buffer to the same original disk location
▪Overwrites old values of any changed data items
– Shadowing
▪Writes an updated buffer at a different disk
location, to maintain multiple versions of data items
▪Not typically used in practice
• Before-image: old value of data item
• After-image: new value of data item
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
Recovery Concepts (6 of 9)
• Write-ahead logging
– Ensure the before-image (BFIM) is recorded
– Appropriate log entry flushed to disk
– Necessary for UNDO operation if needed
• UNDO-type log entries
• REDO-type log entries
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
Recovery Concepts (7 of 9)
• Steal/no-steal and force/no-force
– Specify rules that govern when a page from the
database cache can be written to disk
• No-steal approach
– Cache buffer page updated by a transaction cannot
be written to disk before the transaction commits
• Steal approach
– Recovery protocol allows writing an updated buffer
before the transaction commits
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
Recovery Concepts (8 of 9)
• Force approach
– All pages updated by a transaction are immediately
written to disk before the transaction commits
– Otherwise, no-force
• Typical database systems employ a steal/no-force
strategy
– Avoids need for very large buffer space
– Reduces disk I/O operations for heavily updated
pages
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
Recovery Concepts (9 of 9)
• Write-ahead logging protocol for recovery algorithm
requiring both UNDO and REDO
– BFIM of an item cannot be overwritten by its after
image until all UNDO-type log entries have been
force-written to disk
– Commit operation of a transaction cannot be
completed until all REDO-type and UNDO-type log
records for that transaction have been force-written to
disk
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
Checkpoints in the System Log and Fuzzy
Checkpointing (1 of 2)
• Taking a checkpoint
– Suspend execution of all transactions temporarily
– Force-write all main memory buffers that have been
modified to disk
– Write a checkpoint record to the log, and force-write
the log to the disk
– Resume executing transactions
• DBMS recovery manager decides on checkpoint interval
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
Checkpoints in the System Log and Fuzzy
Checkpointing (2 of 2)
• Fuzzy checkpointing
– System can resume transaction processing after a
begin_checkpoint record is written to the log
– Previous checkpoint record maintained until
end_checkpoint record is written
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
Transaction Rollback
• Transaction failure after update but before commit
– Necessary to roll back the transaction
– Old data values restored using undo-type log entries
• Cascading rollback
– If transaction T is rolled back, any transaction S that
has read value of item written by T must also be rolled
back
– Almost all recovery mechanisms designed to avoid
this
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
Figure 22.1 Illustrating Cascading Rollback (A
Process That Never Occurs in Strict or
Cascadeless Schedules)
(a) The read and write operations of three transactions (b)
System log at point of crash (c) Operations before the crash
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
Transactions That Do Not Affect the
Database
• Example actions: generating and printing messages and
reports
• If transaction fails before completion, may not want user
to get these reports
– Reports should be generated only after transaction
reaches commit point
• Commands that generate reports issued as batch jobs
executed only after transaction reaches commit point
– Batch jobs canceled if transaction fails
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
22.2 NO-UNDO/REDO Recovery Based on
Deferred Update (1 of 3)
• Deferred update concept
– Postpone updates to the database on disk until the
transaction completes successfully and reaches its
commit point
– Redo-type log entries are needed
– Undo-type log entries not necessary
– Can only be used for short transactions and
transactions that change few items
▪Buffer space an issue with longer transactions
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
NO-UNDO/REDO Recovery Based on
Deferred Update (2 of 3)
• Deferred update protocol
– Transaction cannot change the database on disk until
it reaches its commit point
▪All buffers changed by the transaction must be
pinned until the transaction commits (no-steal
policy)
– Transaction does not reach its commit point until all
its REDO-type log entries are recorded in log and log
buffer is force-written to disk
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
NO-UNDO/REDO Recovery Based on
Deferred Update (3 of 3)
Figure 22.2 An example of a recovery timeline to illustrate the effect of
checkpointing
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
22.3 Recovery Techniques Based on
Immediate Update
• Database can be updated immediately
– No need to wait for transaction to reach commit point
– Not a requirement that every update be immediate
• UNDO-type log entries must be stored
• Recovery algorithms
– UNDO/NO-REDO (steal/force strategy)
– UNDO/REDO (steal/no-force strategy)
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
Figure 22.3 An Example of Recovery Using
Deferred Update with Concurrent Transactions
(a) The READ and WRITE operations of four transactions (b) System
log at the point of crash
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
22.4 Shadow Paging (1 of 3)
• No log required in a single-user environment
– Log may be needed in a multiuser environment for the
concurrency control method
• Shadow paging considers disk to be made of n fixed-size
disk pages
– Directory with n entries is constructed
– When transaction begins executing, directory copied
into shadow directory to save while current directory
is being used
– Shadow directory is never modified
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
Shadow Paging (2 of 3)
• New copy of the modified page created and stored
elsewhere
– Current directory modified to point to new disk block
– Shadow directory still points to old disk block
• Failure recovery
– Discard current directory
– Free modified database pages
– NO-UNDO/NO-REDO technique
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
Shadow Paging (3 of 3)
Figure 22.4 An example of shadow paging
5
The directory is similar to the page table maintained by the operating system
for each process.
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
22.5 The ARIES Recovery Algorithm (1 of 3)
• Used in many IBM relational database products
• Uses a steal/no-force approach for writing
• Concepts
– Write-ahead logging
– Repeating history during redo
▪Retrace all database system actions prior to crash
to reconstruct database state when crash occurred
– Logging changes during undo
▪Prevents ARIES from repeating completed undo
operations if failure occurs during recovery
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
The ARIES Recovery Algorithm (2 of 3)
• Analysis step
– Identifies dirty (updated) pages in the buffer and set of
transactions active at the time of crash
– Determines appropriate start point in the log for the
REDO operation
• REDO
– Reapplies updates from the log to the database
– Only necessary REDO operations are applied
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
The ARIES Recovery Algorithm (3 of 3)
• UNDO
– Log is scanned backward
– Operations of transactions that were active at the
time of the crash are undone in reverse order
• Every log record has associated log sequence number
(LSN)
– Indicates address of log record on disk
– Corresponds to a specific change of some
transaction
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
ARIES Recovery Example
Figure 22.5 An example of recovery in ARIES (a) The log at point of crash (b)
The Transaction and Dirty Page Tables at time of checkpoint (c) The
Transaction and Dirty Page Tables after the analysis phase
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
22.6 Recovery in Multidatabase Systems (1 of 2)
• Two-level recovery mechanism
• Global recovery manager (coordinator) needed to
maintain recovery information
• Coordinator follows two-phase commit protocol
– Phase 1: Prepare for commit message
▪Ready to commit or cannot commit signal returned
– Phase 2: Issue commit signal
• Either all participating databases commit the effect of the
transaction or none of them do
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
Recovery in Multidatabase Systems (2 of 2)
• Always possible to recover to a state where either the
transaction is committed or it is rolled back
• Failure during phase 1 requires rollback
• Failure during phase 2 means successful transaction can
recover and commit
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
22.7 Database Backup and Recovery from
Catastrophic Failures (1 of 2)
• Database backup
– Entire database and log periodically copied onto
inexpensive storage medium
– Latest backup copy can be reloaded from disk in case
of catastrophic failure
• Backups often moved to physically separate locations
– Subterranean storage vaults
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
Database Backup and Recovery from
Catastrophic Failures (2 of 2)
• Backup system log at more frequent intervals and copy to
magnetic tape
– System log smaller than database
▪Can be backed up more frequently
– Benefit: users do not lose all transactions since last
database backup
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
22.8 Summary
• Main goal of recovery
– Ensure atomicity property of a transaction
• Caching
• In-place updating versus shadowing
• Before and after images of data items
• UNDO and REDO operations
• Deferred versus immediate update
• Shadow paging
• Catastrophic failure recovery
Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
Copyright

More Related Content

PDF
Database recovery techniques
PPTX
Chapter20 transaction processing system .pptx
PPTX
database recovery techniques
PDF
Presentation recovery manager (rman) configuration and performance tuning ...
PPTX
Backing Up and Recovery
DOC
What is Database Backup? The 3 Important Recovery Techniques from transaction...
PPTX
chapter22 Database Management Lecture Slides .pptx
PPTX
Lec 4 Recovery in database management system.pptx
Database recovery techniques
Chapter20 transaction processing system .pptx
database recovery techniques
Presentation recovery manager (rman) configuration and performance tuning ...
Backing Up and Recovery
What is Database Backup? The 3 Important Recovery Techniques from transaction...
chapter22 Database Management Lecture Slides .pptx
Lec 4 Recovery in database management system.pptx

Similar to Chapter22 database security in dbms.pptx (20)

PDF
January OpenNTF Webinar - Backup your Domino Server - New Options in V12
PDF
4 db recovery
PPT
ELNA6eCh21.ppt
PPT
dbms ppt data base Management System 12
PPT
ELNA6eCh21.ppt
PPT
ELNA6eCh21.ppt
PPT
ELNA6eCh21 (1).ppt
PPT
5-Recovery.ppt
PDF
ch-5 advanced db.pdf
PPT
Backups And Recovery
PDF
Presentation backup and recovery best practices for very large databases (v...
PPT
Chapter19
PPT
Transaction Management system.ppt
PPT
ch 5 Daatabase Recovery.ppt
PPTX
Recovery techniques
PPTX
CSE2010- Module 4 V1.pptx
PDF
Ch8 main memory
PDF
Unit iiios Storage Management
PDF
The Good, The Bad and the Ugly
PPT
Operating System
January OpenNTF Webinar - Backup your Domino Server - New Options in V12
4 db recovery
ELNA6eCh21.ppt
dbms ppt data base Management System 12
ELNA6eCh21.ppt
ELNA6eCh21.ppt
ELNA6eCh21 (1).ppt
5-Recovery.ppt
ch-5 advanced db.pdf
Backups And Recovery
Presentation backup and recovery best practices for very large databases (v...
Chapter19
Transaction Management system.ppt
ch 5 Daatabase Recovery.ppt
Recovery techniques
CSE2010- Module 4 V1.pptx
Ch8 main memory
Unit iiios Storage Management
The Good, The Bad and the Ugly
Operating System
Ad

More from ubaidullah75790 (20)

PPTX
Chapter27 distributed database syst.pptx
PPTX
File Organization in database management.pptx
PPTX
transaction processing databse management.pptx
PPT
physical database design distributed .ppt
PPT
module03-ipaddr ipv6 addressing in net.ppt
PPT
PDBD- Part2 physical database design.ppt
PPT
Physical_Design system development life.PPT
PPT
S3 application and network attacks in.ppt
PPT
Chapter 5 cyber security in computer.ppt
PPTX
1606802425-dba-w7 database management.pptx
PPT
ENCh18 database management system ss.ppt
PPT
Chapter07 database system in computer.ppt
PPT
Chapter05 database sytem in computer . ppt
PPT
Chapter04 database system in computer.ppt
PPT
Chapter03 database system in computer.ppt
PPT
Chapter02 database system in computer.ppt
PPT
Chapter01 database system in computer.ppt
PPT
MYCH8 database management system in .ppt
PPT
ch1 database management system in data.ppt
PPTX
ch12 database management system storage.pptx
Chapter27 distributed database syst.pptx
File Organization in database management.pptx
transaction processing databse management.pptx
physical database design distributed .ppt
module03-ipaddr ipv6 addressing in net.ppt
PDBD- Part2 physical database design.ppt
Physical_Design system development life.PPT
S3 application and network attacks in.ppt
Chapter 5 cyber security in computer.ppt
1606802425-dba-w7 database management.pptx
ENCh18 database management system ss.ppt
Chapter07 database system in computer.ppt
Chapter05 database sytem in computer . ppt
Chapter04 database system in computer.ppt
Chapter03 database system in computer.ppt
Chapter02 database system in computer.ppt
Chapter01 database system in computer.ppt
MYCH8 database management system in .ppt
ch1 database management system in data.ppt
ch12 database management system storage.pptx
Ad

Recently uploaded (20)

PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Pharma ospi slides which help in ospi learning
PDF
Insiders guide to clinical Medicine.pdf
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Classroom Observation Tools for Teachers
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
Cell Types and Its function , kingdom of life
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Final Presentation General Medicine 03-08-2024.pptx
Supply Chain Operations Speaking Notes -ICLT Program
VCE English Exam - Section C Student Revision Booklet
2.FourierTransform-ShortQuestionswithAnswers.pdf
Pharma ospi slides which help in ospi learning
Insiders guide to clinical Medicine.pdf
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPH.pptx obstetrics and gynecology in nursing
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
human mycosis Human fungal infections are called human mycosis..pptx
Microbial diseases, their pathogenesis and prophylaxis
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Classroom Observation Tools for Teachers
102 student loan defaulters named and shamed – Is someone you know on the list?
Anesthesia in Laparoscopic Surgery in India
Abdominal Access Techniques with Prof. Dr. R K Mishra
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
Cell Types and Its function , kingdom of life
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES

Chapter22 database security in dbms.pptx

  • 1. Fundamentals of Database Systems Seventh Edition Chapter 22 Database Recovery Techniques Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved
  • 2. Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved Introduction • Recovery algorithms • Recovery concepts – Write-ahead logging – In-place versus shadow updates – Rollback – Deferred update – Immediate update • Certain recovery techniques best used with specific concurrency control methods
  • 3. Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved 22.1 Recovery Concepts (1 of 9) • Recovery process restores database to most recent consistent state before time of failure • Information kept in system log • Typical recovery strategies – Restore backed-up copy of database ▪Best in cases of extensive damage – Identify any changes that may cause inconsistency ▪Best in cases of noncatastrophic failure ▪Some operations may require redo
  • 4. Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved Recovery Concepts (2 of 9) • Deferred update techniques – Do not physically update the database until after transaction commits – Undo is not needed; redo may be needed • Immediate update techniques – Database may be updated by some operations of a transaction before it reaches commit point – Operations also recorded in log – Recovery still possible
  • 5. Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved Recovery Concepts (3 of 9) • Undo and redo operations required to be idempotent – Executing operations multiple times equivalent to executing just once – Entire recovery process should be idempotent • Caching (buffering) of disk blocks – DBMS cache: a collection of in-memory buffers – Cache directory keeps track of which database items are in the buffers
  • 6. Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved Recovery Concepts (4 of 9) • Cache buffers replaced (flushed) to make space for new items • Dirty bit associated with each buffer in the cache – Indicates whether the buffer has been modified • Contents written back to disk before flush if dirty bit equals one • Pin-unpin bit – Page is pinned if it cannot be written back to disk yet
  • 7. Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved Recovery Concepts (5 of 9) • Main strategies – In-place updating ▪Writes the buffer to the same original disk location ▪Overwrites old values of any changed data items – Shadowing ▪Writes an updated buffer at a different disk location, to maintain multiple versions of data items ▪Not typically used in practice • Before-image: old value of data item • After-image: new value of data item
  • 8. Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved Recovery Concepts (6 of 9) • Write-ahead logging – Ensure the before-image (BFIM) is recorded – Appropriate log entry flushed to disk – Necessary for UNDO operation if needed • UNDO-type log entries • REDO-type log entries
  • 9. Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved Recovery Concepts (7 of 9) • Steal/no-steal and force/no-force – Specify rules that govern when a page from the database cache can be written to disk • No-steal approach – Cache buffer page updated by a transaction cannot be written to disk before the transaction commits • Steal approach – Recovery protocol allows writing an updated buffer before the transaction commits
  • 10. Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved Recovery Concepts (8 of 9) • Force approach – All pages updated by a transaction are immediately written to disk before the transaction commits – Otherwise, no-force • Typical database systems employ a steal/no-force strategy – Avoids need for very large buffer space – Reduces disk I/O operations for heavily updated pages
  • 11. Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved Recovery Concepts (9 of 9) • Write-ahead logging protocol for recovery algorithm requiring both UNDO and REDO – BFIM of an item cannot be overwritten by its after image until all UNDO-type log entries have been force-written to disk – Commit operation of a transaction cannot be completed until all REDO-type and UNDO-type log records for that transaction have been force-written to disk
  • 12. Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved Checkpoints in the System Log and Fuzzy Checkpointing (1 of 2) • Taking a checkpoint – Suspend execution of all transactions temporarily – Force-write all main memory buffers that have been modified to disk – Write a checkpoint record to the log, and force-write the log to the disk – Resume executing transactions • DBMS recovery manager decides on checkpoint interval
  • 13. Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved Checkpoints in the System Log and Fuzzy Checkpointing (2 of 2) • Fuzzy checkpointing – System can resume transaction processing after a begin_checkpoint record is written to the log – Previous checkpoint record maintained until end_checkpoint record is written
  • 14. Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved Transaction Rollback • Transaction failure after update but before commit – Necessary to roll back the transaction – Old data values restored using undo-type log entries • Cascading rollback – If transaction T is rolled back, any transaction S that has read value of item written by T must also be rolled back – Almost all recovery mechanisms designed to avoid this
  • 15. Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved Figure 22.1 Illustrating Cascading Rollback (A Process That Never Occurs in Strict or Cascadeless Schedules) (a) The read and write operations of three transactions (b) System log at point of crash (c) Operations before the crash
  • 16. Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved Transactions That Do Not Affect the Database • Example actions: generating and printing messages and reports • If transaction fails before completion, may not want user to get these reports – Reports should be generated only after transaction reaches commit point • Commands that generate reports issued as batch jobs executed only after transaction reaches commit point – Batch jobs canceled if transaction fails
  • 17. Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved 22.2 NO-UNDO/REDO Recovery Based on Deferred Update (1 of 3) • Deferred update concept – Postpone updates to the database on disk until the transaction completes successfully and reaches its commit point – Redo-type log entries are needed – Undo-type log entries not necessary – Can only be used for short transactions and transactions that change few items ▪Buffer space an issue with longer transactions
  • 18. Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved NO-UNDO/REDO Recovery Based on Deferred Update (2 of 3) • Deferred update protocol – Transaction cannot change the database on disk until it reaches its commit point ▪All buffers changed by the transaction must be pinned until the transaction commits (no-steal policy) – Transaction does not reach its commit point until all its REDO-type log entries are recorded in log and log buffer is force-written to disk
  • 19. Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved NO-UNDO/REDO Recovery Based on Deferred Update (3 of 3) Figure 22.2 An example of a recovery timeline to illustrate the effect of checkpointing
  • 20. Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved 22.3 Recovery Techniques Based on Immediate Update • Database can be updated immediately – No need to wait for transaction to reach commit point – Not a requirement that every update be immediate • UNDO-type log entries must be stored • Recovery algorithms – UNDO/NO-REDO (steal/force strategy) – UNDO/REDO (steal/no-force strategy)
  • 21. Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved Figure 22.3 An Example of Recovery Using Deferred Update with Concurrent Transactions (a) The READ and WRITE operations of four transactions (b) System log at the point of crash
  • 22. Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved 22.4 Shadow Paging (1 of 3) • No log required in a single-user environment – Log may be needed in a multiuser environment for the concurrency control method • Shadow paging considers disk to be made of n fixed-size disk pages – Directory with n entries is constructed – When transaction begins executing, directory copied into shadow directory to save while current directory is being used – Shadow directory is never modified
  • 23. Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved Shadow Paging (2 of 3) • New copy of the modified page created and stored elsewhere – Current directory modified to point to new disk block – Shadow directory still points to old disk block • Failure recovery – Discard current directory – Free modified database pages – NO-UNDO/NO-REDO technique
  • 24. Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved Shadow Paging (3 of 3) Figure 22.4 An example of shadow paging 5 The directory is similar to the page table maintained by the operating system for each process.
  • 25. Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved 22.5 The ARIES Recovery Algorithm (1 of 3) • Used in many IBM relational database products • Uses a steal/no-force approach for writing • Concepts – Write-ahead logging – Repeating history during redo ▪Retrace all database system actions prior to crash to reconstruct database state when crash occurred – Logging changes during undo ▪Prevents ARIES from repeating completed undo operations if failure occurs during recovery
  • 26. Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved The ARIES Recovery Algorithm (2 of 3) • Analysis step – Identifies dirty (updated) pages in the buffer and set of transactions active at the time of crash – Determines appropriate start point in the log for the REDO operation • REDO – Reapplies updates from the log to the database – Only necessary REDO operations are applied
  • 27. Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved The ARIES Recovery Algorithm (3 of 3) • UNDO – Log is scanned backward – Operations of transactions that were active at the time of the crash are undone in reverse order • Every log record has associated log sequence number (LSN) – Indicates address of log record on disk – Corresponds to a specific change of some transaction
  • 28. Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved ARIES Recovery Example Figure 22.5 An example of recovery in ARIES (a) The log at point of crash (b) The Transaction and Dirty Page Tables at time of checkpoint (c) The Transaction and Dirty Page Tables after the analysis phase
  • 29. Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved 22.6 Recovery in Multidatabase Systems (1 of 2) • Two-level recovery mechanism • Global recovery manager (coordinator) needed to maintain recovery information • Coordinator follows two-phase commit protocol – Phase 1: Prepare for commit message ▪Ready to commit or cannot commit signal returned – Phase 2: Issue commit signal • Either all participating databases commit the effect of the transaction or none of them do
  • 30. Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved Recovery in Multidatabase Systems (2 of 2) • Always possible to recover to a state where either the transaction is committed or it is rolled back • Failure during phase 1 requires rollback • Failure during phase 2 means successful transaction can recover and commit
  • 31. Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved 22.7 Database Backup and Recovery from Catastrophic Failures (1 of 2) • Database backup – Entire database and log periodically copied onto inexpensive storage medium – Latest backup copy can be reloaded from disk in case of catastrophic failure • Backups often moved to physically separate locations – Subterranean storage vaults
  • 32. Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved Database Backup and Recovery from Catastrophic Failures (2 of 2) • Backup system log at more frequent intervals and copy to magnetic tape – System log smaller than database ▪Can be backed up more frequently – Benefit: users do not lose all transactions since last database backup
  • 33. Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved 22.8 Summary • Main goal of recovery – Ensure atomicity property of a transaction • Caching • In-place updating versus shadowing • Before and after images of data items • UNDO and REDO operations • Deferred versus immediate update • Shadow paging • Catastrophic failure recovery
  • 34. Copyright © 2016, 2011, 2007 Pearson Education, Inc. All Rights Reserved Copyright

Editor's Notes

  • #1: If this PowerPoint presentation contains mathematical equations, you may need to check that your computer has the following installed: 1) MathType Plugin 2) Math Player (free versions available) 3) NVDA Reader (free versions available)