SlideShare une entreprise Scribd logo
1  sur  81
Télécharger pour lire hors ligne
Chapter 17: Recovery System



           Version:  Oct 5, 2006



         Database System Concepts
         ©Silberschatz, Korth and Sudarshan
    See www.db­book.com for conditions on re­use 
Chapter 17: Recovery System
             s Failure Classification
             s Storage Structure
             s Recovery and Atomicity
             s Log­Based Recovery
             s Shadow Paging
             s Recovery With Concurrent Transactions
             s Buffer Management
             s Failure with Loss of Nonvolatile Storage
             s Advanced Recovery Techniques
             s ARIES Recovery Algorithm
             s Remote Backup Systems




Database System Concepts, 5th Ed.            17.<number>   ©Silberschatz, Korth and Sudarshan
Failure Classification
            s Transaction failure :
                   q    Logical errors: transaction cannot complete due to some internal 
                        error condition
                   q    System errors: the database system must terminate an active 
                        transaction due to an error condition (e.g., deadlock)
            s System crash: a power failure or other hardware or software failure 
                  causes the system to crash.
                   q    Fail­stop assumption: non­volatile storage contents are assumed 
                        to not be corrupted by system crash
                             Database systems have numerous integrity checks to prevent 
                              corruption of disk data 
            s Disk failure: a head crash or similar disk failure destroys all or part of 
                  disk storage
                   q    Destruction is assumed to be detectable: disk drives use 
                        checksums to detect failures


Database System Concepts, 5th Ed.                  17.<number>             ©Silberschatz, Korth and Sudarshan
Recovery Algorithms
            s     Recovery algorithms are techniques to ensure database consistency 
                  and transaction atomicity and durability despite failures
                   q     Focus of this chapter
            s     Recovery algorithms have two parts
                   1.    Actions taken during normal transaction processing to ensure 
                         enough information exists to recover from failures
                   2.    Actions taken after a failure to recover the database contents to a 
                         state that ensures atomicity, consistency and durability




Database System Concepts, 5th Ed.                  17.<number>               ©Silberschatz, Korth and Sudarshan
Storage Structure
            s Volatile storage:
                   q    does not survive system crashes
                   q    examples: main memory, cache memory
            s Nonvolatile storage:
                   q    survives system crashes
                   q    examples: disk, tape, flash memory, 
                                          non­volatile (battery backed up) RAM 
            s Stable storage:
                   q    a mythical form of storage that survives all failures
                   q    approximated by maintaining multiple copies on distinct nonvolatile 
                        media




Database System Concepts, 5th Ed.                    17.<number>                  ©Silberschatz, Korth and Sudarshan
Stable­Storage Implementation
            s Maintain multiple copies of each block on separate disks
                   q    copies can be at remote sites to protect against disasters such as 
                        fire or flooding.
            s Failure during data transfer can still result in inconsistent copies: Block 
                  transfer can result in
                   q    Successful completion
                   q    Partial failure: destination block has incorrect information
                   q    Total failure: destination block was never updated
            s Protecting storage media from failure during data transfer (one 
                  solution):
                   q    Execute output operation as follows (assuming two copies of each 
                        block):
                          1.   Write the information onto the first physical block.
                          2.   When the first write successfully completes, write the same 
                               information onto the second physical block.
                          3.   The output is completed only after the second write 
                               successfully completes.

Database System Concepts, 5th Ed.                     17.<number>                ©Silberschatz, Korth and Sudarshan
Stable­Storage Implementation (Cont.)

             s     Protecting storage media from failure during data transfer (cont.):
             s     Copies of a block may differ due to failure during output operation. To 
                   recover from failure:
                    1.   First find inconsistent blocks:
                          1.    Expensive solution: Compare the two copies of every disk block.
                          2.    Better solution: 
                                q   Record in­progress disk writes on non­volatile storage (Non­
                                    volatile RAM or special area of disk). 
                                q    Use this information during recovery  to find blocks that may be 
                                    inconsistent, and only compare copies of these. 
                                q   Used in hardware RAID systems
                    2.   If either copy of an inconsistent block is detected to have an error (bad 
                         checksum), overwrite it by the other copy.  If both have no error, but are 
                         different, overwrite the second block by the first block.   



Database System Concepts, 5th Ed.                     17.<number>               ©Silberschatz, Korth and Sudarshan
Data Access
            s Physical blocks are those blocks residing on the disk. 
            s Buffer blocks are the blocks residing temporarily in main memory.
            s Block movements between  disk and main memory are initiated 
                  through the following two operations:
                   q    input(B) transfers the physical block B  to main memory.
                   q    output(B) transfers the buffer block B to the disk, and replaces the 
                        appropriate physical block there.
            s Each transaction T  has its private work­area in which local copies of 
                                i
                  all data items accessed and updated by it are kept.
                   q     Ti's local copy of a data item X is called xi.
            s We assume, for simplicity, that each data item fits in, and is stored 
                  inside, a single block.




Database System Concepts, 5th Ed.                    17.<number>            ©Silberschatz, Korth and Sudarshan
Data Access (Cont.)
            s Transaction transfers data items between system buffer blocks and its 
                  private work­area using the following operations :
                   q    read(X) assigns the value of data item X to the local variable xi.

                   q    write(X) assigns the value of local variable xi to data item {X} in 
                        the buffer block.
                   q    both these commands may necessitate the issue of an input(BX) 
                        instruction before the assignment, if the block BX in which X 
                        resides is not already in memory.
            s Transactions 
                   q    Perform read(X) while accessing X for the first time; 
                   q    All subsequent accesses are to the local copy. 
                   q    After last access, transaction executes write(X).
            s output(BX) need not immediately follow write(X). System can perform 
                  the output operation when it deems fit.

Database System Concepts, 5th Ed.                   17.<number>               ©Silberschatz, Korth and Sudarshan
Example of Data Access
                                                buffer
                        Buffer Block A                          input(A)
                                                  X                                   A
                        Buffer Block B            Y                                   B
                                                                output(B) 
                                      read(X)
                                                  write(Y)

                                                    x2
                                         x1
                                         y1 

                                      work area     work area
                                      of T1         of T2 

                                                   memory                       disk

Database System Concepts, 5th Ed.                 17.<number>                ©Silberschatz, Korth and Sudarshan
Recovery and Atomicity
             s Modifying the database without ensuring that the transaction will commit 
                   may leave the database in an inconsistent state.
             s Consider transaction Ti that transfers $50 from account A to account B;  
                  goal is either to perform all database modifications made by Ti or none 
                  at all. 
             s Several output operations may be required for Ti  (to output A and B). A 
                  failure may occur after one of these modifications have been made but 
                  before all of them are made.




Database System Concepts, 5th Ed.               17.<number>               ©Silberschatz, Korth and Sudarshan
Recovery and Atomicity (Cont.)
            s To ensure atomicity despite failures, we first output information 
                  describing the modifications to stable storage without modifying the 
                  database itself.
            s We study two approaches:
                   q    log­based recovery, and
                   q    shadow­paging
            s We assume (initially) that transactions run serially, that is, one after 
                  the other.




Database System Concepts, 5th Ed.                 17.<number>             ©Silberschatz, Korth and Sudarshan
Log­Based Recovery
             s A  log is kept on stable storage. 
                    qThe log is a sequence of log records, and maintains a record of 
                     update activities on the database.
             s When transaction Ti starts, it registers itself by writing a 
                      <Ti  start>log record
             s Before Ti executes write(X), a log record <Ti, X,  V1,  V2> is written, 
                  where V1 is the value of X  before the write, and V2 is the value to be 
                  written to X.
                   q Log record notes that Ti has performed a write on data item Xj   Xj 
                       had value V1 before the write, and will have value V2 after the write. 
             s When Ti finishes it last statement, the log record <Ti  commit> is written. 
             s We assume for now that log records are written directly  to stable 
                  storage (that is, they are not buffered)
             s Two approaches using logs
                    q   Deferred database modification
                    q   Immediate database modification

Database System Concepts, 5th Ed.                17.<number>                ©Silberschatz, Korth and Sudarshan
Deferred Database Modification
             s The deferred database modification scheme records all 
                  modifications to the log, but defers all the writes to after partial 
                  commit.
             s Assume that transactions execute serially
             s Transaction starts by writing <Ti  start> record to log. 

             s A  write(X) operation results in a log record  <Ti, X, V> being written, 
                  where V is the new value for X
                    q   Note: old value is not needed for this scheme
             s The write is not performed on X at this time, but is deferred.
             s When Ti partially commits, <Ti commit> is written to the log 
             s Finally, the log records are read and used to actually execute the 
                  previously deferred writes.




Database System Concepts, 5th Ed.                 17.<number>                 ©Silberschatz, Korth and Sudarshan
Deferred Database Modification (Cont.)
             s During recovery after a crash, a transaction needs to be redone if and 
                  only if both <Ti  start> and<Ti commit> are there in the log.
             s Redoing a transaction Ti ( redoTi) sets the value of all data items updated 
                  by the transaction to the new values.
             s Crashes can occur while 
                    q   the transaction is executing the original updates, or 
                    q   while recovery action is being taken
             s example transactions  T0 and T1 (T0 executes before T1):

                  T0: read (A)                                   T1 : read (C)
                           A: ­ A ­ 50                                  C:­ C­ 100
                           Write (A)                                     write (C)
                           read (B)
                           B:­  B + 50
                           write (B)

Database System Concepts, 5th Ed.                  17.<number>                   ©Silberschatz, Korth and Sudarshan
Deferred Database Modification (Cont.)
             s Below we show the log as it appears at three instances of time.




             s If log on stable storage at time of crash is as in case:
               (a)  No redo actions need to be taken
               (b)  redo(T0) must be performed since <T0 commit> is present 
                   (c)  redo(T0) must be performed followed by redo(T1) since
                           <T0 commit> and <Ti commit> are present




Database System Concepts, 5th Ed.                  17.<number>                  ©Silberschatz, Korth and Sudarshan
Immediate Database Modification
            s The immediate database modification scheme allows database 
                  updates of an uncommitted transaction to be made as the writes are 
                  issued
                   q    since undoing may be needed, update logs must have both old 
                        value and new value
            s Update log record must be written before database item is written
                   q    We assume that the log record is output directly to stable storage
                   q    Can be extended to postpone log record output, so long as prior to 
                        execution of an output(B) operation for a data block B, all log 
                        records corresponding to items B must be flushed to stable 
                        storage
            s Output of updated blocks can take place at any time before or  after 
                  transaction commit
            s Order in which blocks are output can be different from the order in 
                  which they are written.



Database System Concepts, 5th Ed.                 17.<number>               ©Silberschatz, Korth and Sudarshan
Immediate Database Modification Example
            Log                                  Write                              Output

            <T0 start>
            <T0, A, 1000, 950>
            To, B, 2000, 2050
                                                A = 950
                                                B = 2050
            <T0 commit>
            <T1 start>
                        x1
            <T1, C, 700, 600>
                                                  C = 600
                                                                                     BB, BC
            <T1 commit>
                                                                                     BA
            s     Note: BX denotes block containing X.




Database System Concepts, 5th Ed.                                    17.<number>              ©Silberschatz, Korth and Sudarshan
Immediate Database Modification (Cont.)
             s Recovery procedure has two operations instead of one:
                    q    undo(Ti) restores the value of all data items updated by Ti to their 
                        old values, going backwards from the last log record for Ti
                    q   redo(Ti) sets the value of all data items updated by Ti to the new 
                        values, going forward from the first log record for Ti
             s Both operations must be idempotent
                    q   That is, even if the operation is executed multiple times the effect is 
                        the same as if it is executed once
                             Needed since operations may get re­executed during recovery 
             s When recovering after failure:
                    q   Transaction Ti needs to be undone if the log contains the record 
                        <Ti start>, but does not contain the record <Ti commit>.
                    q   Transaction Ti needs to be redone if the log contains both the record 
                        <Ti start> and the record <Ti commit>.
             s Undo operations are performed first, then redo operations.



Database System Concepts, 5th Ed.                  17.<number>                ©Silberschatz, Korth and Sudarshan
Immediate DB Modification Recovery 
                              Example
               Below we show the log as it appears at three instances of time.




             Recovery actions in each case above are:
             (a)  undo (T0): B is restored to 2000 and A to 1000.
             (b)  undo (T1) and redo (T0): C is restored to 700, and then A and B are  
                    set to 950 and 2050 respectively.
             (c)  redo (T0) and redo (T1): A and B are set to 950 and 2050 
                    respectively. Then C is set to 600




Database System Concepts, 5th Ed.                    17.<number>                 ©Silberschatz, Korth and Sudarshan
Checkpoints
            s     Problems in recovery procedure as discussed earlier :
                   1.    searching the entire log is time­consuming
                   2.    we might unnecessarily redo transactions which have already
                   3.    output their updates to the database.
            s     Streamline recovery procedure by periodically performing 
                  checkpointing 
                   1.    Output all log records currently residing in main memory onto 
                         stable storage.
                   2.    Output all modified buffer blocks to the disk.
                   3.    Write a log record < checkpoint> onto stable storage.




Database System Concepts, 5th Ed.                   17.<number>             ©Silberschatz, Korth and Sudarshan
Checkpoints (Cont.)
            s     During recovery we need to consider only the most recent transaction 
                  Ti that started before the checkpoint, and transactions that started 
                  after Ti. 
                   1.    Scan backwards from end of log to find the most recent 
                         <checkpoint> record 
                   2.    Continue scanning backwards till a record <Ti start> is found. 
                   3.    Need only consider the part of log following above start record. 
                         Earlier part of log can be ignored during recovery, and can be 
                         erased whenever desired.
                   4.    For all transactions (starting from Ti or later) with no <Ti commit>, 
                         execute undo(Ti). (Done only in case of immediate modification.)
                   5.    Scanning forward in the log, for all transactions starting 
                         from Ti or later with a <Ti  commit>,  execute redo(Ti).




Database System Concepts, 5th Ed.                   17.<number>                ©Silberschatz, Korth and Sudarshan
Example of Checkpoints

                                       Tc                             Tf
                              T1
                                        T2
                                                 T3
                                                                 T4


                                    checkpoint                 system failure
             s T1 can be ignored (updates already output to disk due to checkpoint)

             s T2 and T3 redone.

             s T4 undone




Database System Concepts, 5th Ed.                17.<number>                    ©Silberschatz, Korth and Sudarshan
Recovery With Concurrent Transactions
             s We modify the log­based recovery schemes to allow multiple 
                  transactions to execute concurrently.
                    q   All transactions share a single disk buffer and a single log
                    q   A buffer block can have data items updated by one or more 
                        transactions
             s We assume concurrency control using strict two­phase locking;
                    q   i.e. the updates of uncommitted transactions should not be visible to 
                        other transactions
                             Otherwise how to perform undo if T1 updates A, then T2 updates 
                              A and commits, and finally T1 has to abort?
             s Logging is done as described earlier. 
                    q   Log records of different transactions may be interspersed in the log.
             s The checkpointing technique and actions taken on recovery have to be 
                  changed
                    q   since several transactions may be active when a checkpoint is 
                        performed.


Database System Concepts, 5th Ed.                  17.<number>               ©Silberschatz, Korth and Sudarshan
Recovery With Concurrent Transactions (Cont.)
             s     Checkpoints are performed as before, except that the checkpoint log record 
                   is now of the form 
                        < checkpoint L>
                   where L is the list of transactions active at the time of the checkpoint
                    q    We assume no updates are in progress while the checkpoint is carried 
                         out (will relax this later)
             s     When the system recovers from a crash, it first does the following:
                    1.   Initialize  undo­list and  redo­list to empty
                    2.   Scan the log backwards from the end, stopping when the first 
                         <checkpoint L> record is found.  
                         For each record found during the backward scan:
                         5 if the record is <Ti commit>, add Ti to redo­list

                          5if the record is <Ti  start>, then if Ti is not in  redo­list, add Ti to undo­
                           list
                    3. For every Ti in L, if Ti is not in  redo­list, add Ti to undo­list




Database System Concepts, 5th Ed.                    17.<number>                ©Silberschatz, Korth and Sudarshan
Recovery With Concurrent Transactions (Cont.)

            s     At this point undo­list consists of incomplete transactions which must 
                  be undone, and redo­list consists of finished transactions that must be 
                  redone.
            s     Recovery now continues as follows:
                   1.    Scan log backwards from most recent record, stopping when 
                         <Ti start> records have been encountered for every Ti in undo­
                         list.
                          s    During the scan, perform undo for each log record that 
                               belongs to a transaction in  undo­list.
                   2.    Locate the most recent <checkpoint L> record.
                   3.    Scan log forwards from the <checkpoint L> record  till the end of 
                         the log.
                          s    During the scan, perform redo for each log record that 
                               belongs to a transaction on  redo­list




Database System Concepts, 5th Ed.                   17.<number>               ©Silberschatz, Korth and Sudarshan
Example of Recovery
            s Go over the steps of the recovery algorithm on the following log:
                                    <T0 start>
                                    <T0, A, 0, 10>
                                    <T0 commit>
                                    <T1 start>         /* Scan at step 1 comes up to here */
                                    <T1, B, 0, 10>
                                    <T2 start>                   
                                    <T2, C, 0, 10>
                                    <T2, C, 10, 20>
                                    <checkpoint {T1, T2}>
                                    <T3 start>
                                    <T3, A, 10, 20>
                                    <T3, D, 0, 10>
                                    <T3 commit>

Database System Concepts, 5th Ed.                          17.<number>            ©Silberschatz, Korth and Sudarshan
Log Record Buffering
             s Log record buffering: log records are buffered in main memory, instead 
                  of of being output directly to stable storage.
                    q   Log records are output to stable storage when a block of log records 
                        in the buffer is full, or a log force operation is executed.
             s Log force is performed to commit a transaction by forcing all its log 
                  records (including the commit record) to stable storage.
             s Several log records can thus be output using a single output operation, 
                  reducing the I/O cost.




Database System Concepts, 5th Ed.                 17.<number>              ©Silberschatz, Korth and Sudarshan
Log Record Buffering (Cont.)
            s The rules below must be followed if log records are buffered:
                   q    Log records are output to stable storage in the order in which they 
                        are created. 
                   q    Transaction Ti enters the commit state only when the log record 
                        <Ti commit> has been output to stable storage.
                   q    Before a block of data in main memory is output to the database, 
                        all log records pertaining to data in that block must have been 
                        output to stable storage. 
                             This rule is called the write­ahead logging or WAL rule
                               – Strictly speaking WAL only requires undo information to be 
                                 output




Database System Concepts, 5th Ed.                   17.<number>              ©Silberschatz, Korth and Sudarshan
Database Buffering
             s Database maintains an in­memory buffer of data blocks
                    q    When a new block is needed, if buffer is full an existing block needs to 
                         be removed from buffer
                    q    If the block chosen for removal has been updated, it must be output to 
                         disk
             s If a block with uncommitted updates is output to disk, log records with undo 
                  information for the updates are output to the log on stable storage first
                    q    (Write ahead logging)
             s No updates should be in progress on a block when it is output to disk.  Can 
                  be ensured as follows.
                    q    Before writing a data item, transaction acquires exclusive lock on block 
                         containing the data item
                    q    Lock can be released once the write is completed. 
                             Such locks held for short duration are called latches.
                    q    Before a block is output to disk, the system acquires an exclusive latch 
                         on the block
                             Ensures no update can be in progress on the block

Database System Concepts, 5th Ed.                    17.<number>              ©Silberschatz, Korth and Sudarshan
Buffer Management (Cont.)
            s Database buffer can be implemented either
                   q    in an area of real main­memory reserved for the database, or
                   q    in virtual memory
            s Implementing buffer in reserved main­memory has drawbacks:
                   q    Memory is partitioned before­hand between database buffer and 
                        applications, limiting flexibility.  
                   q    Needs may change, and although operating system knows best 
                        how memory should be divided up at any time, it cannot change 
                        the partitioning of memory.




Database System Concepts, 5th Ed.                17.<number>              ©Silberschatz, Korth and Sudarshan
Buffer Management (Cont.)
             s Database buffers are generally implemented in virtual memory in spite 
                  of some drawbacks: 
                    q    When operating system needs to evict a page that has been 
                         modified, the page is written to swap space on disk.
                    q    When database decides to write buffer page to disk, buffer page 
                         may be in swap space, and may have to be  read from swap space 
                         on disk and output to the database on disk, resulting in extra I/O! 
                               Known as dual paging problem.
                    q    Ideally when OS needs to evict a page from the buffer, it should 
                         pass control to database, which in turn should
                          1.    Output the page to database instead of to swap space (making 
                                sure to output log records first), if it is modified
                          2.    Release the page from the buffer, for the OS to use
                          Dual paging can thus be avoided, but common operating systems 
                            do not support such functionality.




Database System Concepts, 5th Ed.                    17.<number>              ©Silberschatz, Korth and Sudarshan
Failure with Loss of Nonvolatile Storage
             s So far we assumed no loss of non­volatile storage
             s Technique similar to checkpointing used to deal with loss of non­
                  volatile storage
                    q   Periodically dump the entire content of the database to stable 
                        storage
                    q   No transaction may be active during the dump procedure; a 
                        procedure similar to checkpointing must take place
                             Output all log records currently residing in main memory onto 
                              stable storage.
                             Output all buffer blocks onto the disk.
                             Copy the contents of the database to stable storage.
                             Output a record <dump> to log on stable storage.




Database System Concepts, 5th Ed.                   17.<number>            ©Silberschatz, Korth and Sudarshan
Recovering from Failure of Non­Volatile Storage
            s To recover from disk failure
                   q    restore database from  most recent dump. 
                   q    Consult the log and redo all transactions that committed after 
                        the dump
            s Can be extended to allow transactions to be active during dump; 
                  known as fuzzy dump or online dump
                   q    Will study fuzzy checkpointing later




Database System Concepts, 5th Ed.                17.<number>             ©Silberschatz, Korth and Sudarshan
Advanced Recovery Algorithm




          Database System Concepts
          ©Silberschatz, Korth and Sudarshan
     See www.db­book.com for conditions on re­use 
Advanced Recovery: Key Features
            s Support for high­concurrency locking techniques, such as those used 
                  for B+­tree concurrency control, which release locks early
                   q    Supports “logical undo”
            s Recovery based on “repeating history”, whereby recovery executes 
                  exactly the same actions as normal processing
                   q    including redo of log records of incomplete transactions, followed 
                        by subsequent undo
                   q    Key benefits
                             supports logical undo
                             easier to understand/show correctness




Database System Concepts, 5th Ed.                     17.<number>           ©Silberschatz, Korth and Sudarshan
Advanced Recovery: Logical Undo Logging
             s Operations like B+­tree insertions and deletions release locks early. 
                    q   They cannot be undone by restoring old values (physical undo), 
                        since once a lock is released, other transactions may have updated  
                        the B+­tree.
                    q   Instead, insertions (resp. deletions) are undone  by executing a 
                        deletion (resp. insertion) operation (known as logical undo).  
             s For such operations, undo log records should contain the undo operation 
                  to be executed
                    q   Such logging is called logical undo logging, in contrast to physical 
                        undo logging
                             Operations are called logical operations
                    q   Other examples:
                             delete of tuple, to undo insert of tuple 
                               – allows early lock release on space allocation information
                             subtract amount deposited, to undo deposit
                                – allows early lock release on bank balance


Database System Concepts, 5th Ed.                     17.<number>             ©Silberschatz, Korth and Sudarshan
Advanced Recovery: Physical Redo
            s Redo information is logged physically (that is, new value for each 
                  write) even for operations with logical undo
                   q    Logical redo is very complicated since database state on disk may 
                        not be “operation consistent” when recovery starts
                   q    Physical redo logging does not conflict with early lock release




Database System Concepts, 5th Ed.                  17.<number>               ©Silberschatz, Korth and Sudarshan
Advanced Recovery: Operation Logging
             s Operation logging is done as follows:
                    1.   When operation starts, log <Ti, Oj,  operation­begin>. Here Oj is a 
                         unique identifier of the operation instance.
                    2.   While operation is executing, normal log records with physical redo 
                         and physical undo information are logged. 
                    3.   When operation completes, <Ti, Oj,  operation­end, U> is logged, 
                         where U contains information  needed to perform a logical undo 
                         information.
             Example: insert of (key, record­id) pair (K5, RID7) into index I9
                                    <T1, O1, operation­begin>
                                    ….
                                    <T1, X, 10, K5>        Physical redo of steps in insert
                                    <T1, Y, 45, RID7>
                                    <T1, O1, operation­end, (delete I9, K5, RID7)>



Database System Concepts, 5th Ed.                         17.<number>                  ©Silberschatz, Korth and Sudarshan
Advanced Recovery: Operation Logging (Cont.)
            s If crash/rollback occurs before operation completes:
                   q    the operation­end log record is not found, and 
                   q    the physical undo information is used to undo operation.
            s If crash/rollback occurs after the operation completes:
                   q    the operation­end log record is found, and in this case
                   q    logical undo is performed using U;  the physical undo information 
                        for the operation is ignored.
            s Redo of operation (after crash) still uses physical redo information.




Database System Concepts, 5th Ed.                 17.<number>               ©Silberschatz, Korth and Sudarshan
Advanced Recovery: Txn Rollback
             Rollback of transaction Ti is done as follows: 
             s     Scan the log backwards 
                    1.   If a log record <Ti, X, V1, V2> is found, perform the undo and log a 
                         special redo­only log record <Ti, X, V1>.
                    2.   If a <Ti, Oj,  operation­end, U> record is found
                               Rollback the operation logically using  the undo information U. 
                                – Updates performed during roll back are logged just like 
                                  during normal operation execution.  
                                – At the end of the operation rollback, instead of logging an  
                                  operation­end record, generate a record 
                                      <Ti, Oj, operation­abort>.
                               Skip all preceding log records for Ti  until the record
                                 <Ti, Oj operation­begin>  is found



Database System Concepts, 5th Ed.                      17.<number>                ©Silberschatz, Korth and Sudarshan
Advanced Recovery: Txn Rollback (Cont.)

            s     Scan the log backwards (cont.):
                   1.    If a redo­only record is found ignore it
                   2.    If a <Ti, Oj, operation­abort> record is found:
                          5    skip all preceding log records for Ti  until the record 
                               <Ti, Oj, operation­begin> is found.
                   3.    Stop the scan when the record <Ti, start> is found
                   4.    Add a <Ti,  abort> record to the log
            Some points to note:
            s     Cases 3 and 4 above can occur only if the database crashes while a  
                  transaction is being rolled back.
            s     Skipping of log records as in case 4 is important to prevent multiple 
                  rollback of the same operation.




Database System Concepts, 5th Ed.                     17.<number>                 ©Silberschatz, Korth and Sudarshan
Advanced Recovery: Txn Rollback Example

            s Example with a complete and an incomplete operation

               <T1, start>
               <T1, O1, operation­begin>
               ….
               <T1, X, 10, K5>
               <T1, Y, 45, RID7>
               <T1, O1, operation­end, (delete I9, K5, RID7)>
               <T1, O2, operation­begin> 
               <T1, Z, 45, 70>   
                                        T1 Rollback begins here
               <T1, Z, 45>      redo­only log record during physical undo (of incomplete O2)
               <T1, Y, .., ..>    Normal redo records for logical undo of O1
                    …
               <T1, O1, operation­abort>   What if crash occurred immediately after this?
               <T1, abort>
Database System Concepts, 5th Ed.                       17.<number>             ©Silberschatz, Korth and Sudarshan
Advanced Recovery: Crash Recovery
            The following actions are taken when recovering from  system crash
            2.    (Redo phase): Scan log forward from last < checkpoint L> record till 
                  end of log
                   1.    Repeat history by physically redoing all updates of  all 
                         transactions, 
                   2.    Create an undo­list during the scan as follows
                              undo­list is set to L initially
                              Whenever <Ti start> is found Ti is added to undo­list
                              Whenever <Ti commit> or <Ti abort> is found, Ti is deleted 
                               from undo­list
                  This brings database to state as of crash, with committed as well as 
                  uncommitted transactions having been redone.
                  Now  undo­list contains transactions that are incomplete, that is, 
                  have neither committed nor been fully rolled back.



Database System Concepts, 5th Ed.                       17.<number>           ©Silberschatz, Korth and Sudarshan
Advanced Recovery: Crash Recovery (Cont.)

             Recovery from system crash (cont.)
             2.    (Undo phase): Scan log backwards, performing undo on log records 
                   of transactions found in undo­list.  
                    q    Log records of transactions being rolled back are processed as 
                         described earlier, as they are found
                               Single shared scan for all transactions being undone
                    q    When <Ti  start> is found for a transaction Ti in  undo­list, write a 
                         <Ti abort> log record.
                    q    Stop scan when <Ti start> records have been found for all Ti in  
                         undo­list
             s     This undoes the effects of incomplete transactions (those with neither 
                   commit nor abort log records). Recovery is now complete.




Database System Concepts, 5th Ed.                    17.<number>               ©Silberschatz, Korth and Sudarshan
Advanced Recovery: Checkpointing
            s     Checkpointing is done as follows:
                   1.    Output all log records in memory to stable storage
                   2.    Output to disk all modified buffer blocks
                   3.    Output to log on stable storage a < checkpoint L> record.
                Transactions are not allowed to perform any actions while 
                checkpointing is in progress.
            s     Fuzzy checkpointing allows transactions to progress while the most 
                  time consuming parts of checkpointing are in progress
                   q     Performed as described on next slide




Database System Concepts, 5th Ed.                  17.<number>                ©Silberschatz, Korth and Sudarshan
Advanced Recovery: Fuzzy Checkpointing
             s     Fuzzy checkpointing is done as follows:
                    1.   Temporarily stop all updates by transactions
                    2.   Write a <checkpoint L> log record and force log to stable storage
                    3.   Note list M of modified buffer blocks
                    4.   Now permit transactions to proceed with their actions
                    5.   Output to disk all modified buffer blocks in list M
                          5     blocks should not be updated while being output
                          5     Follow WAL: all log records pertaining to a block must be output 
                                before the block is output
                    6.   Store a pointer to the checkpoint record in a fixed position 
                         last_checkpoint on disk
                                                                       ……
                                                                   <checkpoint L>
                                                                        …..
                                                                   <checkpoint L>
                   last_checkpoint
                                                                        …..

                                                                      Log
Database System Concepts, 5th Ed.                    17.<number>                    ©Silberschatz, Korth and Sudarshan
Advanced Rec: Fuzzy Checkpointing (Cont.)
            s When recovering using a fuzzy checkpoint, start scan from the 
                  checkpoint record pointed to by  last_checkpoint
                   q    Log records before  last_checkpoint have their updates reflected 
                        in database on disk, and need not be redone.
                   q    Incomplete checkpoints, where system had crashed while 
                        performing checkpoint, are handled safely




Database System Concepts, 5th Ed.                17.<number>              ©Silberschatz, Korth and Sudarshan
ARIES Recovery Algorithm




        Database System Concepts
        ©Silberschatz, Korth and Sudarshan
   See www.db­book.com for conditions on re­use 
ARIES
            s     ARIES is a state of the art recovery method 
                   q     Incorporates numerous optimizations to reduce overheads during 
                         normal processing and to speed up recovery 
                   q     The “advanced recovery algorithm” we studied earlier is modeled 
                         after ARIES, but greatly simplified by removing optimizations
            s     Unlike the advanced recovery algorithm, ARIES 
                   1.    Uses log sequence number (LSN) to identify log records
                              Stores LSNs in pages to identify what updates have already 
                               been applied to a database page
                   2.    Physiological redo
                   3.    Dirty page table to avoid unnecessary redos during recovery
                   4.    Fuzzy checkpointing that only records information about dirty 
                         pages, and does not require dirty pages to be written out at 
                         checkpoint time
                              More coming up on each of the above …



Database System Concepts, 5th Ed.                   17.<number>             ©Silberschatz, Korth and Sudarshan
ARIES Optimizations
             s     Physiological redo
                    q    Affected page is physically identified, action within page can be 
                         logical
                               Used to reduce logging overheads
                                –  e.g. when a record is deleted and all other records have to be 
                                  moved to fill hole
                                    »   Physiological redo can log just the record deletion 
                                    »   Physical redo would require logging of old and new values 
                                        for much of the page
                               Requires page to be output to disk atomically
                                – Easy to achieve with hardware RAID, also supported by some 
                                  disk systems
                                – Incomplete page output can be detected by checksum 
                                  techniques, 
                                    »   But extra actions are required for recovery 
                                    »   Treated as a media failure


Database System Concepts, 5th Ed.                      17.<number>               ©Silberschatz, Korth and Sudarshan
ARIES Data Structures
             s ARIES uses several data structures
                    q   Log sequence number (LSN) identifies each log record
                             Must be sequentially increasing
                             Typically an offset from beginning of log file to allow fast access
                                – Easily extended to handle multiple log files
                    q   Page LSN
                    q   Log records of several different types
                    q   Dirty page table




Database System Concepts, 5th Ed.                     17.<number>                ©Silberschatz, Korth and Sudarshan
ARIES Data Structures: Page LSN
            s Each page contains a PageLSN which is the LSN of the last log 
                  record whose effects are reflected on the page
                   q    To update a page:
                             X­latch the page, and write the log record 
                             Update the page
                             Record the LSN of the log record in PageLSN
                             Unlock page
                   q    To flush page to disk, must first S­latch page
                             Thus page state on disk is operation consistent
                               – Required to support physiological redo
                   q    PageLSN is used during recovery to prevent repeated redo 
                             Thus ensuring idempotence




Database System Concepts, 5th Ed.                    17.<number>                ©Silberschatz, Korth and Sudarshan
ARIES Data Structures: Log Record
      s Each log record contains LSN of previous log record of the same transaction

                            LSN TransID PrevLSN RedoInfo                UndoInfo
             q   LSN in log record may be implicit
      s Special redo­only log record called compensation log record (CLR) used to 
           log actions taken during recovery that never need to be undone
             q   Serves the role of operation­abort log records used in advanced recovery 
                 algorithm
             q   Has a field UndoNextLSN to note next (earlier) record to be undone
                      Records in between would have already been undone
                      Required to avoid repeated undo of already undone actions

                                    LSN  TransID  UndoNextLSN   RedoInfo

                           1         2     3     4       4'        3'
                                                                          2'      1'

Database System Concepts, 5th Ed.                    17.<number>               ©Silberschatz, Korth and Sudarshan
ARIES Data Structures: DirtyPage Table
             s DirtyPageTable
                    q   List of pages in the buffer that have been updated
                    q   Contains, for each such page
                             PageLSN of the page
                             RecLSN is an LSN such that log records before this LSN have 
                              already been applied to the page version on disk
                                – Set to current end of log when a page is inserted into dirty 
                                  page table (just before being updated)
     Page LSNs 
     on disk                    – Recorded in checkpoints, helps to minimize redo work

                                    P1        P6             P23
        P1   16                                                                 Page PLSN RLSN
                                    25        16             19
        …                                                                       P1       25     17
        P6   12                                                                 P6       16     15
        ..
                                                                                P23     19     18
        P15   9                     P15
        ..
                                    9
        P23 11                                       Buffer Pool                 DirtyPage Table

Database System Concepts, 5th Ed.                     17.<number>               ©Silberschatz, Korth and Sudarshan
ARIES Data Structures: Checkpoint Log
            s Checkpoint log record
                   q    Contains: 
                             DirtyPageTable and list of active transactions
                             For each active transaction, LastLSN, the LSN of the last log 
                              record written by the transaction
                   q    Fixed position on disk notes LSN of last completed
                        checkpoint log record
            s Dirty pages are not written out at checkpoint time
                             Instead, they are flushed out continuously, in the background
            s Checkpoint is thus very low overhead
                   q    can be done frequently




Database System Concepts, 5th Ed.                    17.<number>               ©Silberschatz, Korth and Sudarshan
ARIES Recovery Algorithm
             ARIES recovery involves three passes
             s Analysis pass: Determines
                    q   Which transactions to undo
                    q   Which pages were dirty (disk version not up to date) at time of crash
                    q   RedoLSN: LSN from which redo should start
             s Redo pass:
                    q   Repeats history, redoing all actions from RedoLSN 
                             RecLSN and PageLSNs are used to avoid redoing actions already 
                              reflected on page 
             s Undo pass:
                    q   Rolls back all incomplete transactions
                             Transactions whose abort was complete earlier are not undone
                                – Key idea: no need to undo these transactions: earlier undo 
                                  actions were logged, and are redone as required


Database System Concepts, 5th Ed.                    17.<number>              ©Silberschatz, Korth and Sudarshan
Aries Recovery: 3 Passes
            s Analysis, redo and undo passes
            s Analysis determines where redo should start
            s Undo has to go back till start of earliest incomplete transaction




                                                      Last checkpoint           End of Log
                                                                                              Time


        Log                                                         Analysis pass
                                            Redo pass

                                                             Undo pass




Database System Concepts, 5th Ed.             17.<number>                ©Silberschatz, Korth and Sudarshan
ARIES Recovery: Analysis

          Analysis pass
          s Starts from last complete checkpoint log record
                 q    Reads DirtyPageTable from log record
                 q    Sets RedoLSN = min of RecLSNs of all pages in DirtyPageTable
                           In case no pages are dirty, RedoLSN = checkpoint record’s 
                            LSN
                 q    Sets undo­list = list of transactions in checkpoint log record
                 q    Reads LSN of last log record for each transaction in undo­list from 
                      checkpoint log record
          s Scans forward from checkpoint
          s .. Cont. on next page …




Database System Concepts, 5th Ed.                  17.<number>               ©Silberschatz, Korth and Sudarshan
ARIES Recovery: Analysis (Cont.)
             Analysis pass (cont.)
             s Scans forward from checkpoint
                    q   If any log record found for transaction not in undo­list, adds 
                        transaction to undo­list
                    q   Whenever an update log record is found
                             If page is not in DirtyPageTable, it is added with RecLSN set to 
                              LSN of the update log record
                    q   If transaction end log record found, delete transaction from undo­list
                    q   Keeps track of last log record for each transaction in undo­list
                             May be needed for later undo
             s At end of analysis pass:
                    q   RedoLSN determines where to start redo pass
                    q   RecLSN for each page in DirtyPageTable used to minimize redo work
                    q   All transactions in undo­list need to be rolled back


Database System Concepts, 5th Ed.                    17.<number>               ©Silberschatz, Korth and Sudarshan
ARIES Redo Pass
            Redo Pass: Repeats history by replaying every action not already 
               reflected in the page on disk, as follows:
            s     Scans forward from RedoLSN.  Whenever an update log record is 
                  found:
                   1.    If the page is not in DirtyPageTable or the LSN of the log record is 
                         less than the RecLSN of the page in DirtyPageTable, then skip 
                         the log record
                   2.    Otherwise fetch the page from disk.  If the PageLSN of the page 
                         fetched from disk is less than the LSN of the log record, redo the 
                         log record
                   NOTE: if either test is negative the effects of the log record have 
                     already appeared on the page.  First test avoids even fetching the 
                     page from disk!




Database System Concepts, 5th Ed.                  17.<number>               ©Silberschatz, Korth and Sudarshan
ARIES Undo Actions
             s When an undo is performed for an update log record
                    q   Generate a CLR containing the undo action performed (actions 
                        performed during undo are logged physicaly or physiologically). 
                             CLR for   record n noted as n’ in figure below
                    q   Set UndoNextLSN of the CLR to the PrevLSN value of the update log 
                        record
                             Arrows indicate UndoNextLSN value
             s ARIES supports partial rollback
                    q   Used e.g. to handle deadlocks by rolling back just enough to release 
                        reqd. locks
                    q   Figure indicates forward actions after partial rollbacks 
                             records 3 and 4 initially, later 5 and 6, then full rollback
       1          2           3      4       4'       3'        5     6      6'       5' 2'              1'



Database System Concepts, 5th Ed.                     17.<number>                 ©Silberschatz, Korth and Sudarshan
ARIES: Undo Pass
             Undo pass:
             s Performs backward scan on log undoing all transaction in undo­list
                    q   Backward scan optimized by skipping unneeded log records as follows:
                             Next LSN to be undone for each transaction set to LSN of last log 
                              record for transaction found by analysis pass.
                             At each step pick largest of these LSNs to undo, skip back to it and 
                              undo it 
                             After undoing a log record
                                – For ordinary log records, set next LSN to be undone for 
                                  transaction to PrevLSN noted in the log record
                                – For compensation log records (CLRs) set next LSN to be undo to 
                                  UndoNextLSN noted in the log record
                                    »   All intervening records are skipped since they would have 
                                        been undone already
             s Undos performed as described earlier


Database System Concepts, 5th Ed.                      17.<number>               ©Silberschatz, Korth and Sudarshan
Other ARIES Features
            s Recovery Independence
                    q   Pages can be recovered independently of others
                             E.g. if some disk pages fail they can be recovered from a backup 
                              while other pages are being used
            s Savepoints:
                    q   Transactions can record savepoints and roll back to a savepoint
                             Useful for complex transactions
                             Also used to rollback just enough to release locks on deadlock




Database System Concepts, 5th Ed.                   17.<number>              ©Silberschatz, Korth and Sudarshan
Other ARIES Features (Cont.)
            s Fine­grained locking:
                   q    Index concurrency algorithms that permit tuple level locking on 
                        indices can be used
                             These require logical undo, rather than physical undo, as in 
                              advanced recovery algorithm
            s Recovery optimizations:  For example:
                   q    Dirty page table can be used to prefetch pages during redo
                   q    Out of order redo is possible:
                              redo can be postponed on a page being fetched from disk, 
                              and
                               performed when page is fetched.  
                             Meanwhile other log records can continue to be processed




Database System Concepts, 5th Ed.                    17.<number>               ©Silberschatz, Korth and Sudarshan
Remote Backup Systems




       Database System Concepts
       ©Silberschatz, Korth and Sudarshan
  See www.db­book.com for conditions on re­use 
Remote Backup Systems
             s Remote backup systems provide high availability by allowing transaction 
                  processing to continue even if the primary site is destroyed.




Database System Concepts, 5th Ed.               17.<number>               ©Silberschatz, Korth and Sudarshan
Remote Backup Systems (Cont.)
             s Detection of failure: Backup site must detect when primary site has 
                  failed 
                    q   to distinguish primary site failure from link failure maintain several 
                        communication links between the primary and the remote backup.
                    q   Heart­beat messages
             s Transfer of control: 
                    q   To take over control backup site first perform recovery using its copy 
                        of the database and all the long records it has received from the 
                        primary.
                              Thus, completed transactions are redone and incomplete 
                              transactions are rolled back.
                    q   When the backup site takes over processing it becomes the new 
                        primary
                    q   To transfer control back to old primary when it recovers, old primary 
                        must receive redo logs from the old backup and apply all updates 
                        locally.

Database System Concepts, 5th Ed.                   17.<number>                ©Silberschatz, Korth and Sudarshan
Remote Backup Systems (Cont.)

             s Time to recover: To reduce delay in takeover, backup site periodically 
                  proceses the redo log records (in effect, performing recovery from 
                  previous database state), performs a checkpoint, and can then delete 
                  earlier parts of the log. 
             s Hot­Spare configuration permits very fast takeover:
                    q   Backup continually processes redo log record as they arrive, 
                        applying the updates locally.
                    q   When failure of the primary is detected the backup rolls back 
                        incomplete transactions, and is ready to  process new transactions.
             s Alternative to remote backup: distributed database with replicated data
                    q   Remote backup is faster and cheaper, but less tolerant to failure 
                             more on this in Chapter 19




Database System Concepts, 5th Ed.                   17.<number>             ©Silberschatz, Korth and Sudarshan
Remote Backup Systems (Cont.)

             s Ensure durability of updates by delaying transaction commit until update is 
                  logged at backup; avoid this delay by permitting lower degrees of durability.
             s One­safe: commit as soon as transaction’s commit log record is written at 
                  primary
                    q   Problem: updates may not arrive at backup before it takes over.
             s Two­very­safe: commit when transaction’s commit log record is written at 
                  primary and backup
                    q   Reduces availability since transactions cannot commit if either site fails.
             s Two­safe: proceed as in two­very­safe if both primary and backup are 
                  active. If only the primary is active, the transaction commits as soon as is 
                  commit log record is written at the primary. 
                    q   Better availability than two­very­safe; avoids problem of lost 
                        transactions in one­safe. 




Database System Concepts, 5th Ed.                  17.<number>               ©Silberschatz, Korth and Sudarshan
End of Chapter




     Database System Concepts
     ©Silberschatz, Korth and Sudarshan
See www.db­book.com for conditions on re­use 
Shadow Paging
             s Shadow paging is an alternative to log­based recovery; this scheme is 
                  useful if  transactions execute serially
             s Idea: maintain two page tables during the lifetime of a transaction –the 
                  current page table, and the shadow page table
             s Store the shadow page table in nonvolatile storage, such that state of the 
                  database prior to transaction execution may be recovered. 
                    q   Shadow page table is never modified during execution
             s To start with, both the page tables are identical. Only current page table is 
                  used for data item accesses during execution of the transaction.
             s Whenever any page is about to be written for the first time
                    q   A copy of this page is made onto an unused page. 
                    q   The current page table is then made to point to the copy
                    q   The update is performed on the copy




Database System Concepts, 5th Ed.                 17.<number>               ©Silberschatz, Korth and Sudarshan
Sample Page Table




Database System Concepts, 5th Ed.         17.<number>   ©Silberschatz, Korth and Sudarshan
Example of Shadow Paging
                         Shadow and current page tables after write to page 4 




Database System Concepts, 5th Ed.                 17.<number>              ©Silberschatz, Korth and Sudarshan
Shadow Paging (Cont.)
             s To commit a transaction :
               1.  Flush all modified pages in main memory to disk
               2.  Output current page table to disk
               3.  Make the current page table the new shadow page table, as follows:
                    q   keep a pointer to the shadow page table at a fixed (known) location 
                        on disk.
                    q   to make the current page table the new shadow page table, simply 
                        update the pointer to point to current page table on disk
             s Once pointer to shadow page table has been written, transaction is 
                  committed.
             s No recovery is needed after a crash — new transactions can start right 
                  away, using the shadow page table.
             s Pages not pointed to from current/shadow page table should be freed 
                  (garbage collected).



Database System Concepts, 5th Ed.                 17.<number>              ©Silberschatz, Korth and Sudarshan
Show Paging (Cont.)
             s Advantages of shadow­paging over log­based schemes
                    q   no overhead of writing log records
                    q   recovery is trivial
             s Disadvantages :
                    q   Copying the entire page table is very expensive
                             Can be reduced by using a page table structured like a B+­tree
                                – No need to copy entire tree, only need to copy paths in the tree 
                                  that lead to updated leaf nodes
                    q   Commit overhead is high even with above extension
                             Need to flush every updated page, and page table
                    q   Data gets fragmented (related pages get separated on disk)
                    q   After every transaction completion, the database pages containing old 
                        versions of modified data need to be garbage collected 
                    q   Hard to extend algorithm to allow transactions to run concurrently
                             Easier to extend log based schemes


Database System Concepts, 5th Ed.                    17.<number>               ©Silberschatz, Korth and Sudarshan
Block Storage Operations




Database System Concepts, 5th Ed.            17.<number>   ©Silberschatz, Korth and Sudarshan
Portion of the Database Log Corresponding to 
                              T0 and T1




Database System Concepts, 5th Ed.   17.<number>   ©Silberschatz, Korth and Sudarshan
State of the Log and Database Corresponding 
                          to T0 and T1




Database System Concepts, 5th Ed.   17.<number>   ©Silberschatz, Korth and Sudarshan
Portion of the System Log Corresponding to 
                             T0 and T1




Database System Concepts, 5th Ed.   17.<number>   ©Silberschatz, Korth and Sudarshan
State of System Log and Database 
                             Corresponding to T0 and T1




Database System Concepts, 5th Ed.      17.<number>   ©Silberschatz, Korth and Sudarshan

Contenu connexe

Tendances

High Availability Storage (susecon2016)
High Availability Storage (susecon2016)High Availability Storage (susecon2016)
High Availability Storage (susecon2016)Roger Zhou 周志强
 
DaStor/Cassandra report for CDR solution
DaStor/Cassandra report for CDR solutionDaStor/Cassandra report for CDR solution
DaStor/Cassandra report for CDR solutionSchubert Zhang
 
Presentazione laurea 1.2 matteo concas
Presentazione laurea 1.2   matteo concasPresentazione laurea 1.2   matteo concas
Presentazione laurea 1.2 matteo concasMatteo Concas
 
Logging Last Resource Optimization for Distributed Transactions in Oracle…
Logging Last Resource Optimization for Distributed Transactions in  Oracle…Logging Last Resource Optimization for Distributed Transactions in  Oracle…
Logging Last Resource Optimization for Distributed Transactions in Oracle…Gera Shegalov
 
Logging Last Resource Optimization for Distributed Transactions in Oracle We...
Logging Last Resource Optimization for Distributed Transactions in  Oracle We...Logging Last Resource Optimization for Distributed Transactions in  Oracle We...
Logging Last Resource Optimization for Distributed Transactions in Oracle We...Gera Shegalov
 
IJCER (www.ijceronline.com) International Journal of computational Engineeri...
 IJCER (www.ijceronline.com) International Journal of computational Engineeri... IJCER (www.ijceronline.com) International Journal of computational Engineeri...
IJCER (www.ijceronline.com) International Journal of computational Engineeri...ijceronline
 
Cassandra运维之道 v0.2
Cassandra运维之道 v0.2Cassandra运维之道 v0.2
Cassandra运维之道 v0.2haiyuan ning
 
HKG15-The Machine: A new kind of computer- Keynote by Dejan Milojicic
HKG15-The Machine: A new kind of computer- Keynote by Dejan MilojicicHKG15-The Machine: A new kind of computer- Keynote by Dejan Milojicic
HKG15-The Machine: A new kind of computer- Keynote by Dejan MilojicicLinaro
 
Userspace Linux I/O
Userspace Linux I/O Userspace Linux I/O
Userspace Linux I/O Garima Kapoor
 
Trivadis TechEvent 2017 ACFS Replication as of 12 2 by Mathias Zarick
Trivadis TechEvent 2017 ACFS Replication as of 12 2 by Mathias ZarickTrivadis TechEvent 2017 ACFS Replication as of 12 2 by Mathias Zarick
Trivadis TechEvent 2017 ACFS Replication as of 12 2 by Mathias ZarickTrivadis
 
Storage structure
Storage structureStorage structure
Storage structureMohd Arif
 
Hpux AdvFS On Disk Structure Scoping
Hpux AdvFS On Disk Structure ScopingHpux AdvFS On Disk Structure Scoping
Hpux AdvFS On Disk Structure ScopingJustin Goldberg
 

Tendances (16)

Ch23
Ch23Ch23
Ch23
 
High Availability Storage (susecon2016)
High Availability Storage (susecon2016)High Availability Storage (susecon2016)
High Availability Storage (susecon2016)
 
DaStor/Cassandra report for CDR solution
DaStor/Cassandra report for CDR solutionDaStor/Cassandra report for CDR solution
DaStor/Cassandra report for CDR solution
 
Vx vm
Vx vmVx vm
Vx vm
 
Hpc4
Hpc4Hpc4
Hpc4
 
Evaluator Group on TS7680 ProtecTIER for z/OS
Evaluator Group on TS7680 ProtecTIER for z/OSEvaluator Group on TS7680 ProtecTIER for z/OS
Evaluator Group on TS7680 ProtecTIER for z/OS
 
Presentazione laurea 1.2 matteo concas
Presentazione laurea 1.2   matteo concasPresentazione laurea 1.2   matteo concas
Presentazione laurea 1.2 matteo concas
 
Logging Last Resource Optimization for Distributed Transactions in Oracle…
Logging Last Resource Optimization for Distributed Transactions in  Oracle…Logging Last Resource Optimization for Distributed Transactions in  Oracle…
Logging Last Resource Optimization for Distributed Transactions in Oracle…
 
Logging Last Resource Optimization for Distributed Transactions in Oracle We...
Logging Last Resource Optimization for Distributed Transactions in  Oracle We...Logging Last Resource Optimization for Distributed Transactions in  Oracle We...
Logging Last Resource Optimization for Distributed Transactions in Oracle We...
 
IJCER (www.ijceronline.com) International Journal of computational Engineeri...
 IJCER (www.ijceronline.com) International Journal of computational Engineeri... IJCER (www.ijceronline.com) International Journal of computational Engineeri...
IJCER (www.ijceronline.com) International Journal of computational Engineeri...
 
Cassandra运维之道 v0.2
Cassandra运维之道 v0.2Cassandra运维之道 v0.2
Cassandra运维之道 v0.2
 
HKG15-The Machine: A new kind of computer- Keynote by Dejan Milojicic
HKG15-The Machine: A new kind of computer- Keynote by Dejan MilojicicHKG15-The Machine: A new kind of computer- Keynote by Dejan Milojicic
HKG15-The Machine: A new kind of computer- Keynote by Dejan Milojicic
 
Userspace Linux I/O
Userspace Linux I/O Userspace Linux I/O
Userspace Linux I/O
 
Trivadis TechEvent 2017 ACFS Replication as of 12 2 by Mathias Zarick
Trivadis TechEvent 2017 ACFS Replication as of 12 2 by Mathias ZarickTrivadis TechEvent 2017 ACFS Replication as of 12 2 by Mathias Zarick
Trivadis TechEvent 2017 ACFS Replication as of 12 2 by Mathias Zarick
 
Storage structure
Storage structureStorage structure
Storage structure
 
Hpux AdvFS On Disk Structure Scoping
Hpux AdvFS On Disk Structure ScopingHpux AdvFS On Disk Structure Scoping
Hpux AdvFS On Disk Structure Scoping
 

En vedette (13)

Ch12
Ch12Ch12
Ch12
 
Ch14
Ch14Ch14
Ch14
 
Ch9
Ch9Ch9
Ch9
 
Ch19
Ch19Ch19
Ch19
 
Ch9
Ch9Ch9
Ch9
 
Ch1
Ch1Ch1
Ch1
 
Rrelational algebra in dbms overview
Rrelational algebra in dbms overviewRrelational algebra in dbms overview
Rrelational algebra in dbms overview
 
dynamic query forms for data base querys
dynamic query forms for data base querysdynamic query forms for data base querys
dynamic query forms for data base querys
 
Dynamic query
Dynamic queryDynamic query
Dynamic query
 
Ch16
Ch16Ch16
Ch16
 
Ch13
Ch13Ch13
Ch13
 
overview of database concept
overview of database conceptoverview of database concept
overview of database concept
 
C1 basic concepts of database
C1 basic concepts of databaseC1 basic concepts of database
C1 basic concepts of database
 

Similaire à Ch17

Similaire à Ch17 (20)

Recovery Management
Recovery ManagementRecovery Management
Recovery Management
 
Top 17 Data Recovery System
Top 17 Data Recovery SystemTop 17 Data Recovery System
Top 17 Data Recovery System
 
Database recovery
Database recoveryDatabase recovery
Database recovery
 
Ch17
Ch17Ch17
Ch17
 
Ch11
Ch11Ch11
Ch11
 
Ch15
Ch15Ch15
Ch15
 
Database management system chapter15
Database management system chapter15Database management system chapter15
Database management system chapter15
 
Lesson12 recovery architectures
Lesson12 recovery architecturesLesson12 recovery architectures
Lesson12 recovery architectures
 
Memory
MemoryMemory
Memory
 
os
osos
os
 
Ch23
Ch23Ch23
Ch23
 
XPDS13: VIRTUAL DISK INTEGRITY IN REAL TIME JP BLAKE, ASSURED INFORMATION SE...
XPDS13: VIRTUAL DISK INTEGRITY IN REAL TIME  JP BLAKE, ASSURED INFORMATION SE...XPDS13: VIRTUAL DISK INTEGRITY IN REAL TIME  JP BLAKE, ASSURED INFORMATION SE...
XPDS13: VIRTUAL DISK INTEGRITY IN REAL TIME JP BLAKE, ASSURED INFORMATION SE...
 
Recovery system
Recovery systemRecovery system
Recovery system
 
DBMS Unit IV and V Material
DBMS Unit IV and V MaterialDBMS Unit IV and V Material
DBMS Unit IV and V Material
 
Updates
UpdatesUpdates
Updates
 
Updates
UpdatesUpdates
Updates
 
OpenVZ Linux Containers
OpenVZ Linux ContainersOpenVZ Linux Containers
OpenVZ Linux Containers
 
Dbms
DbmsDbms
Dbms
 
Memory model
Memory modelMemory model
Memory model
 
Programming Language Memory Models: What do Shared Variables Mean?
Programming Language Memory Models: What do Shared Variables Mean?Programming Language Memory Models: What do Shared Variables Mean?
Programming Language Memory Models: What do Shared Variables Mean?
 

Plus de Subhankar Chowdhury (11)

Ch20
Ch20Ch20
Ch20
 
Ch10
Ch10Ch10
Ch10
 
Ch8
Ch8Ch8
Ch8
 
Ch7
Ch7Ch7
Ch7
 
Ch6
Ch6Ch6
Ch6
 
Ch5
Ch5Ch5
Ch5
 
Ch4
Ch4Ch4
Ch4
 
Ch3
Ch3Ch3
Ch3
 
Ch2
Ch2Ch2
Ch2
 
Ch22
Ch22Ch22
Ch22
 
Ch21
Ch21Ch21
Ch21
 

Ch17

  • 1. Chapter 17: Recovery System Version:  Oct 5, 2006 Database System Concepts ©Silberschatz, Korth and Sudarshan See www.db­book.com for conditions on re­use 
  • 2. Chapter 17: Recovery System s Failure Classification s Storage Structure s Recovery and Atomicity s Log­Based Recovery s Shadow Paging s Recovery With Concurrent Transactions s Buffer Management s Failure with Loss of Nonvolatile Storage s Advanced Recovery Techniques s ARIES Recovery Algorithm s Remote Backup Systems Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 3. Failure Classification s Transaction failure : q Logical errors: transaction cannot complete due to some internal  error condition q System errors: the database system must terminate an active  transaction due to an error condition (e.g., deadlock) s System crash: a power failure or other hardware or software failure  causes the system to crash. q Fail­stop assumption: non­volatile storage contents are assumed  to not be corrupted by system crash  Database systems have numerous integrity checks to prevent  corruption of disk data  s Disk failure: a head crash or similar disk failure destroys all or part of  disk storage q Destruction is assumed to be detectable: disk drives use  checksums to detect failures Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 4. Recovery Algorithms s Recovery algorithms are techniques to ensure database consistency  and transaction atomicity and durability despite failures q Focus of this chapter s Recovery algorithms have two parts 1. Actions taken during normal transaction processing to ensure  enough information exists to recover from failures 2. Actions taken after a failure to recover the database contents to a  state that ensures atomicity, consistency and durability Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 5. Storage Structure s Volatile storage: q does not survive system crashes q examples: main memory, cache memory s Nonvolatile storage: q survives system crashes q examples: disk, tape, flash memory,                    non­volatile (battery backed up) RAM  s Stable storage: q a mythical form of storage that survives all failures q approximated by maintaining multiple copies on distinct nonvolatile  media Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 6. Stable­Storage Implementation s Maintain multiple copies of each block on separate disks q copies can be at remote sites to protect against disasters such as  fire or flooding. s Failure during data transfer can still result in inconsistent copies: Block  transfer can result in q Successful completion q Partial failure: destination block has incorrect information q Total failure: destination block was never updated s Protecting storage media from failure during data transfer (one  solution): q Execute output operation as follows (assuming two copies of each  block): 1. Write the information onto the first physical block. 2. When the first write successfully completes, write the same  information onto the second physical block. 3. The output is completed only after the second write  successfully completes. Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 7. Stable­Storage Implementation (Cont.) s Protecting storage media from failure during data transfer (cont.): s Copies of a block may differ due to failure during output operation. To  recover from failure: 1. First find inconsistent blocks: 1. Expensive solution: Compare the two copies of every disk block. 2. Better solution:  q Record in­progress disk writes on non­volatile storage (Non­ volatile RAM or special area of disk).  q  Use this information during recovery  to find blocks that may be  inconsistent, and only compare copies of these.  q Used in hardware RAID systems 2. If either copy of an inconsistent block is detected to have an error (bad  checksum), overwrite it by the other copy.  If both have no error, but are  different, overwrite the second block by the first block.    Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 8. Data Access s Physical blocks are those blocks residing on the disk.  s Buffer blocks are the blocks residing temporarily in main memory. s Block movements between  disk and main memory are initiated  through the following two operations: q input(B) transfers the physical block B  to main memory. q output(B) transfers the buffer block B to the disk, and replaces the  appropriate physical block there. s Each transaction T  has its private work­area in which local copies of  i all data items accessed and updated by it are kept. q  Ti's local copy of a data item X is called xi. s We assume, for simplicity, that each data item fits in, and is stored  inside, a single block. Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 9. Data Access (Cont.) s Transaction transfers data items between system buffer blocks and its  private work­area using the following operations : q read(X) assigns the value of data item X to the local variable xi. q write(X) assigns the value of local variable xi to data item {X} in  the buffer block. q both these commands may necessitate the issue of an input(BX)  instruction before the assignment, if the block BX in which X  resides is not already in memory. s Transactions  q Perform read(X) while accessing X for the first time;  q All subsequent accesses are to the local copy.  q After last access, transaction executes write(X). s output(BX) need not immediately follow write(X). System can perform  the output operation when it deems fit. Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 10. Example of Data Access buffer Buffer Block A  input(A) X       A Buffer Block B Y      B output(B)  read(X) write(Y) x2 x1 y1  work area work area of T1 of T2  memory disk Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 11. Recovery and Atomicity s Modifying the database without ensuring that the transaction will commit   may leave the database in an inconsistent state. s Consider transaction Ti that transfers $50 from account A to account B;   goal is either to perform all database modifications made by Ti or none  at all.  s Several output operations may be required for Ti  (to output A and B). A  failure may occur after one of these modifications have been made but  before all of them are made. Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 12. Recovery and Atomicity (Cont.) s To ensure atomicity despite failures, we first output information  describing the modifications to stable storage without modifying the  database itself. s We study two approaches: q log­based recovery, and q shadow­paging s We assume (initially) that transactions run serially, that is, one after  the other. Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 13. Log­Based Recovery s A  log is kept on stable storage.  qThe log is a sequence of log records, and maintains a record of  update activities on the database. s When transaction Ti starts, it registers itself by writing a         <Ti  start>log record s Before Ti executes write(X), a log record <Ti, X,  V1,  V2> is written,  where V1 is the value of X  before the write, and V2 is the value to be  written to X. q Log record notes that Ti has performed a write on data item Xj   Xj  had value V1 before the write, and will have value V2 after the write.  s When Ti finishes it last statement, the log record <Ti  commit> is written.  s We assume for now that log records are written directly  to stable  storage (that is, they are not buffered) s Two approaches using logs q Deferred database modification q Immediate database modification Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 14. Deferred Database Modification s The deferred database modification scheme records all  modifications to the log, but defers all the writes to after partial  commit. s Assume that transactions execute serially s Transaction starts by writing <Ti  start> record to log.  s A  write(X) operation results in a log record  <Ti, X, V> being written,  where V is the new value for X q Note: old value is not needed for this scheme s The write is not performed on X at this time, but is deferred. s When Ti partially commits, <Ti commit> is written to the log  s Finally, the log records are read and used to actually execute the  previously deferred writes. Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 15. Deferred Database Modification (Cont.) s During recovery after a crash, a transaction needs to be redone if and  only if both <Ti  start> and<Ti commit> are there in the log. s Redoing a transaction Ti ( redoTi) sets the value of all data items updated  by the transaction to the new values. s Crashes can occur while  q the transaction is executing the original updates, or  q while recovery action is being taken s example transactions  T0 and T1 (T0 executes before T1): T0: read (A) T1 : read (C) A: ­ A ­ 50        C:­ C­ 100 Write (A)         write (C) read (B) B:­  B + 50 write (B) Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 16. Deferred Database Modification (Cont.) s Below we show the log as it appears at three instances of time. s If log on stable storage at time of crash is as in case: (a)  No redo actions need to be taken (b)  redo(T0) must be performed since <T0 commit> is present  (c)  redo(T0) must be performed followed by redo(T1) since        <T0 commit> and <Ti commit> are present Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 17. Immediate Database Modification s The immediate database modification scheme allows database  updates of an uncommitted transaction to be made as the writes are  issued q since undoing may be needed, update logs must have both old  value and new value s Update log record must be written before database item is written q We assume that the log record is output directly to stable storage q Can be extended to postpone log record output, so long as prior to  execution of an output(B) operation for a data block B, all log  records corresponding to items B must be flushed to stable  storage s Output of updated blocks can take place at any time before or  after  transaction commit s Order in which blocks are output can be different from the order in  which they are written. Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 18. Immediate Database Modification Example Log                                  Write                              Output <T0 start> <T0, A, 1000, 950> To, B, 2000, 2050                                     A = 950                                     B = 2050 <T0 commit> <T1 start> x1 <T1, C, 700, 600>                                       C = 600                                                                          BB, BC <T1 commit>                                                                          BA s Note: BX denotes block containing X. Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 19. Immediate Database Modification (Cont.) s Recovery procedure has two operations instead of one: q  undo(Ti) restores the value of all data items updated by Ti to their  old values, going backwards from the last log record for Ti q redo(Ti) sets the value of all data items updated by Ti to the new  values, going forward from the first log record for Ti s Both operations must be idempotent q That is, even if the operation is executed multiple times the effect is  the same as if it is executed once  Needed since operations may get re­executed during recovery  s When recovering after failure: q Transaction Ti needs to be undone if the log contains the record  <Ti start>, but does not contain the record <Ti commit>. q Transaction Ti needs to be redone if the log contains both the record  <Ti start> and the record <Ti commit>. s Undo operations are performed first, then redo operations. Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 20. Immediate DB Modification Recovery  Example   Below we show the log as it appears at three instances of time. Recovery actions in each case above are: (a)  undo (T0): B is restored to 2000 and A to 1000. (b)  undo (T1) and redo (T0): C is restored to 700, and then A and B are          set to 950 and 2050 respectively. (c)  redo (T0) and redo (T1): A and B are set to 950 and 2050         respectively. Then C is set to 600 Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 21. Checkpoints s Problems in recovery procedure as discussed earlier : 1. searching the entire log is time­consuming 2. we might unnecessarily redo transactions which have already 3. output their updates to the database. s Streamline recovery procedure by periodically performing  checkpointing  1. Output all log records currently residing in main memory onto  stable storage. 2. Output all modified buffer blocks to the disk. 3. Write a log record < checkpoint> onto stable storage. Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 22. Checkpoints (Cont.) s During recovery we need to consider only the most recent transaction  Ti that started before the checkpoint, and transactions that started  after Ti.  1. Scan backwards from end of log to find the most recent  <checkpoint> record  2. Continue scanning backwards till a record <Ti start> is found.  3. Need only consider the part of log following above start record.  Earlier part of log can be ignored during recovery, and can be  erased whenever desired. 4. For all transactions (starting from Ti or later) with no <Ti commit>,  execute undo(Ti). (Done only in case of immediate modification.) 5. Scanning forward in the log, for all transactions starting  from Ti or later with a <Ti  commit>,  execute redo(Ti). Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 23. Example of Checkpoints Tc Tf T1 T2 T3 T4 checkpoint system failure s T1 can be ignored (updates already output to disk due to checkpoint) s T2 and T3 redone. s T4 undone Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 24. Recovery With Concurrent Transactions s We modify the log­based recovery schemes to allow multiple  transactions to execute concurrently. q All transactions share a single disk buffer and a single log q A buffer block can have data items updated by one or more  transactions s We assume concurrency control using strict two­phase locking; q i.e. the updates of uncommitted transactions should not be visible to  other transactions  Otherwise how to perform undo if T1 updates A, then T2 updates  A and commits, and finally T1 has to abort? s Logging is done as described earlier.  q Log records of different transactions may be interspersed in the log. s The checkpointing technique and actions taken on recovery have to be  changed q since several transactions may be active when a checkpoint is  performed. Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 25. Recovery With Concurrent Transactions (Cont.) s Checkpoints are performed as before, except that the checkpoint log record  is now of the form  < checkpoint L> where L is the list of transactions active at the time of the checkpoint q We assume no updates are in progress while the checkpoint is carried  out (will relax this later) s When the system recovers from a crash, it first does the following: 1. Initialize  undo­list and  redo­list to empty 2. Scan the log backwards from the end, stopping when the first  <checkpoint L> record is found.   For each record found during the backward scan: 5 if the record is <Ti commit>, add Ti to redo­list 5if the record is <Ti  start>, then if Ti is not in  redo­list, add Ti to undo­ list 3. For every Ti in L, if Ti is not in  redo­list, add Ti to undo­list Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 26. Recovery With Concurrent Transactions (Cont.) s At this point undo­list consists of incomplete transactions which must  be undone, and redo­list consists of finished transactions that must be  redone. s Recovery now continues as follows: 1. Scan log backwards from most recent record, stopping when  <Ti start> records have been encountered for every Ti in undo­ list. s During the scan, perform undo for each log record that  belongs to a transaction in  undo­list. 2. Locate the most recent <checkpoint L> record. 3. Scan log forwards from the <checkpoint L> record  till the end of  the log. s During the scan, perform redo for each log record that  belongs to a transaction on  redo­list Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 27. Example of Recovery s Go over the steps of the recovery algorithm on the following log: <T0 start> <T0, A, 0, 10> <T0 commit> <T1 start>         /* Scan at step 1 comes up to here */ <T1, B, 0, 10> <T2 start>                    <T2, C, 0, 10> <T2, C, 10, 20> <checkpoint {T1, T2}> <T3 start> <T3, A, 10, 20> <T3, D, 0, 10> <T3 commit> Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 28. Log Record Buffering s Log record buffering: log records are buffered in main memory, instead  of of being output directly to stable storage. q Log records are output to stable storage when a block of log records  in the buffer is full, or a log force operation is executed. s Log force is performed to commit a transaction by forcing all its log  records (including the commit record) to stable storage. s Several log records can thus be output using a single output operation,  reducing the I/O cost. Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 29. Log Record Buffering (Cont.) s The rules below must be followed if log records are buffered: q Log records are output to stable storage in the order in which they  are created.  q Transaction Ti enters the commit state only when the log record  <Ti commit> has been output to stable storage. q Before a block of data in main memory is output to the database,  all log records pertaining to data in that block must have been  output to stable storage.   This rule is called the write­ahead logging or WAL rule – Strictly speaking WAL only requires undo information to be  output Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 30. Database Buffering s Database maintains an in­memory buffer of data blocks q When a new block is needed, if buffer is full an existing block needs to  be removed from buffer q If the block chosen for removal has been updated, it must be output to  disk s If a block with uncommitted updates is output to disk, log records with undo  information for the updates are output to the log on stable storage first q (Write ahead logging) s No updates should be in progress on a block when it is output to disk.  Can  be ensured as follows. q Before writing a data item, transaction acquires exclusive lock on block  containing the data item q Lock can be released once the write is completed.   Such locks held for short duration are called latches. q Before a block is output to disk, the system acquires an exclusive latch  on the block  Ensures no update can be in progress on the block Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 31. Buffer Management (Cont.) s Database buffer can be implemented either q in an area of real main­memory reserved for the database, or q in virtual memory s Implementing buffer in reserved main­memory has drawbacks: q Memory is partitioned before­hand between database buffer and  applications, limiting flexibility.   q Needs may change, and although operating system knows best  how memory should be divided up at any time, it cannot change  the partitioning of memory. Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 32. Buffer Management (Cont.) s Database buffers are generally implemented in virtual memory in spite  of some drawbacks:  q When operating system needs to evict a page that has been  modified, the page is written to swap space on disk. q When database decides to write buffer page to disk, buffer page  may be in swap space, and may have to be  read from swap space  on disk and output to the database on disk, resulting in extra I/O!   Known as dual paging problem. q Ideally when OS needs to evict a page from the buffer, it should  pass control to database, which in turn should 1. Output the page to database instead of to swap space (making  sure to output log records first), if it is modified 2. Release the page from the buffer, for the OS to use Dual paging can thus be avoided, but common operating systems  do not support such functionality. Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 33. Failure with Loss of Nonvolatile Storage s So far we assumed no loss of non­volatile storage s Technique similar to checkpointing used to deal with loss of non­ volatile storage q Periodically dump the entire content of the database to stable  storage q No transaction may be active during the dump procedure; a  procedure similar to checkpointing must take place  Output all log records currently residing in main memory onto  stable storage.  Output all buffer blocks onto the disk.  Copy the contents of the database to stable storage.  Output a record <dump> to log on stable storage. Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 34. Recovering from Failure of Non­Volatile Storage s To recover from disk failure q restore database from  most recent dump.  q Consult the log and redo all transactions that committed after  the dump s Can be extended to allow transactions to be active during dump;  known as fuzzy dump or online dump q Will study fuzzy checkpointing later Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 35. Advanced Recovery Algorithm Database System Concepts ©Silberschatz, Korth and Sudarshan See www.db­book.com for conditions on re­use 
  • 36. Advanced Recovery: Key Features s Support for high­concurrency locking techniques, such as those used  for B+­tree concurrency control, which release locks early q Supports “logical undo” s Recovery based on “repeating history”, whereby recovery executes  exactly the same actions as normal processing q including redo of log records of incomplete transactions, followed  by subsequent undo q Key benefits  supports logical undo  easier to understand/show correctness Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 37. Advanced Recovery: Logical Undo Logging s Operations like B+­tree insertions and deletions release locks early.  q They cannot be undone by restoring old values (physical undo),  since once a lock is released, other transactions may have updated   the B+­tree. q Instead, insertions (resp. deletions) are undone  by executing a  deletion (resp. insertion) operation (known as logical undo).   s For such operations, undo log records should contain the undo operation  to be executed q Such logging is called logical undo logging, in contrast to physical  undo logging  Operations are called logical operations q Other examples:  delete of tuple, to undo insert of tuple  – allows early lock release on space allocation information  subtract amount deposited, to undo deposit – allows early lock release on bank balance Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 38. Advanced Recovery: Physical Redo s Redo information is logged physically (that is, new value for each  write) even for operations with logical undo q Logical redo is very complicated since database state on disk may  not be “operation consistent” when recovery starts q Physical redo logging does not conflict with early lock release Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 39. Advanced Recovery: Operation Logging s Operation logging is done as follows: 1. When operation starts, log <Ti, Oj,  operation­begin>. Here Oj is a  unique identifier of the operation instance. 2. While operation is executing, normal log records with physical redo  and physical undo information are logged.  3. When operation completes, <Ti, Oj,  operation­end, U> is logged,  where U contains information  needed to perform a logical undo  information. Example: insert of (key, record­id) pair (K5, RID7) into index I9 <T1, O1, operation­begin> …. <T1, X, 10, K5> Physical redo of steps in insert <T1, Y, 45, RID7> <T1, O1, operation­end, (delete I9, K5, RID7)> Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 40. Advanced Recovery: Operation Logging (Cont.) s If crash/rollback occurs before operation completes: q the operation­end log record is not found, and  q the physical undo information is used to undo operation. s If crash/rollback occurs after the operation completes: q the operation­end log record is found, and in this case q logical undo is performed using U;  the physical undo information  for the operation is ignored. s Redo of operation (after crash) still uses physical redo information. Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 41. Advanced Recovery: Txn Rollback Rollback of transaction Ti is done as follows:  s Scan the log backwards  1. If a log record <Ti, X, V1, V2> is found, perform the undo and log a  special redo­only log record <Ti, X, V1>. 2. If a <Ti, Oj,  operation­end, U> record is found  Rollback the operation logically using  the undo information U.  – Updates performed during roll back are logged just like  during normal operation execution.   – At the end of the operation rollback, instead of logging an   operation­end record, generate a record          <Ti, Oj, operation­abort>.  Skip all preceding log records for Ti  until the record  <Ti, Oj operation­begin>  is found Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 42. Advanced Recovery: Txn Rollback (Cont.) s Scan the log backwards (cont.): 1. If a redo­only record is found ignore it 2. If a <Ti, Oj, operation­abort> record is found: 5 skip all preceding log records for Ti  until the record  <Ti, Oj, operation­begin> is found. 3. Stop the scan when the record <Ti, start> is found 4. Add a <Ti,  abort> record to the log Some points to note: s Cases 3 and 4 above can occur only if the database crashes while a   transaction is being rolled back. s Skipping of log records as in case 4 is important to prevent multiple  rollback of the same operation. Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 43. Advanced Recovery: Txn Rollback Example s Example with a complete and an incomplete operation <T1, start> <T1, O1, operation­begin> …. <T1, X, 10, K5> <T1, Y, 45, RID7> <T1, O1, operation­end, (delete I9, K5, RID7)> <T1, O2, operation­begin>  <T1, Z, 45, 70>                             T1 Rollback begins here <T1, Z, 45>      redo­only log record during physical undo (of incomplete O2) <T1, Y, .., ..>    Normal redo records for logical undo of O1      … <T1, O1, operation­abort>   What if crash occurred immediately after this? <T1, abort> Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 44. Advanced Recovery: Crash Recovery The following actions are taken when recovering from  system crash 2. (Redo phase): Scan log forward from last < checkpoint L> record till  end of log 1. Repeat history by physically redoing all updates of  all  transactions,  2. Create an undo­list during the scan as follows  undo­list is set to L initially  Whenever <Ti start> is found Ti is added to undo­list  Whenever <Ti commit> or <Ti abort> is found, Ti is deleted  from undo­list This brings database to state as of crash, with committed as well as  uncommitted transactions having been redone. Now  undo­list contains transactions that are incomplete, that is,  have neither committed nor been fully rolled back. Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 45. Advanced Recovery: Crash Recovery (Cont.) Recovery from system crash (cont.) 2. (Undo phase): Scan log backwards, performing undo on log records  of transactions found in undo­list.   q Log records of transactions being rolled back are processed as  described earlier, as they are found  Single shared scan for all transactions being undone q When <Ti  start> is found for a transaction Ti in  undo­list, write a  <Ti abort> log record. q Stop scan when <Ti start> records have been found for all Ti in   undo­list s This undoes the effects of incomplete transactions (those with neither  commit nor abort log records). Recovery is now complete. Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 46. Advanced Recovery: Checkpointing s Checkpointing is done as follows: 1. Output all log records in memory to stable storage 2. Output to disk all modified buffer blocks 3. Output to log on stable storage a < checkpoint L> record.     Transactions are not allowed to perform any actions while  checkpointing is in progress. s Fuzzy checkpointing allows transactions to progress while the most  time consuming parts of checkpointing are in progress q Performed as described on next slide Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 47. Advanced Recovery: Fuzzy Checkpointing s Fuzzy checkpointing is done as follows: 1. Temporarily stop all updates by transactions 2. Write a <checkpoint L> log record and force log to stable storage 3. Note list M of modified buffer blocks 4. Now permit transactions to proceed with their actions 5. Output to disk all modified buffer blocks in list M 5 blocks should not be updated while being output 5 Follow WAL: all log records pertaining to a block must be output  before the block is output 6. Store a pointer to the checkpoint record in a fixed position  last_checkpoint on disk …… <checkpoint L> ….. <checkpoint L> last_checkpoint ….. Log Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 48. Advanced Rec: Fuzzy Checkpointing (Cont.) s When recovering using a fuzzy checkpoint, start scan from the  checkpoint record pointed to by  last_checkpoint q Log records before  last_checkpoint have their updates reflected  in database on disk, and need not be redone. q Incomplete checkpoints, where system had crashed while  performing checkpoint, are handled safely Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 49. ARIES Recovery Algorithm Database System Concepts ©Silberschatz, Korth and Sudarshan See www.db­book.com for conditions on re­use 
  • 50. ARIES s ARIES is a state of the art recovery method  q Incorporates numerous optimizations to reduce overheads during  normal processing and to speed up recovery  q The “advanced recovery algorithm” we studied earlier is modeled  after ARIES, but greatly simplified by removing optimizations s Unlike the advanced recovery algorithm, ARIES  1. Uses log sequence number (LSN) to identify log records  Stores LSNs in pages to identify what updates have already  been applied to a database page 2. Physiological redo 3. Dirty page table to avoid unnecessary redos during recovery 4. Fuzzy checkpointing that only records information about dirty  pages, and does not require dirty pages to be written out at  checkpoint time  More coming up on each of the above … Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 51. ARIES Optimizations s Physiological redo q Affected page is physically identified, action within page can be  logical  Used to reduce logging overheads –  e.g. when a record is deleted and all other records have to be  moved to fill hole » Physiological redo can log just the record deletion  » Physical redo would require logging of old and new values  for much of the page  Requires page to be output to disk atomically – Easy to achieve with hardware RAID, also supported by some  disk systems – Incomplete page output can be detected by checksum  techniques,  » But extra actions are required for recovery  » Treated as a media failure Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 52. ARIES Data Structures s ARIES uses several data structures q Log sequence number (LSN) identifies each log record  Must be sequentially increasing  Typically an offset from beginning of log file to allow fast access – Easily extended to handle multiple log files q Page LSN q Log records of several different types q Dirty page table Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 53. ARIES Data Structures: Page LSN s Each page contains a PageLSN which is the LSN of the last log  record whose effects are reflected on the page q To update a page:  X­latch the page, and write the log record   Update the page  Record the LSN of the log record in PageLSN  Unlock page q To flush page to disk, must first S­latch page  Thus page state on disk is operation consistent – Required to support physiological redo q PageLSN is used during recovery to prevent repeated redo   Thus ensuring idempotence Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 54. ARIES Data Structures: Log Record s Each log record contains LSN of previous log record of the same transaction LSN TransID PrevLSN RedoInfo UndoInfo q LSN in log record may be implicit s Special redo­only log record called compensation log record (CLR) used to  log actions taken during recovery that never need to be undone q Serves the role of operation­abort log records used in advanced recovery  algorithm q Has a field UndoNextLSN to note next (earlier) record to be undone  Records in between would have already been undone  Required to avoid repeated undo of already undone actions LSN  TransID  UndoNextLSN   RedoInfo 1 2 3 4 4' 3' 2' 1' Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 55. ARIES Data Structures: DirtyPage Table s DirtyPageTable q List of pages in the buffer that have been updated q Contains, for each such page  PageLSN of the page  RecLSN is an LSN such that log records before this LSN have  already been applied to the page version on disk – Set to current end of log when a page is inserted into dirty  page table (just before being updated) Page LSNs  on disk – Recorded in checkpoints, helps to minimize redo work P1 P6 P23 P1   16 Page PLSN RLSN 25 16 19 … P1       25     17 P6   12 P6       16     15 .. P23     19     18 P15   9 P15 .. 9 P23 11 Buffer Pool DirtyPage Table Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 56. ARIES Data Structures: Checkpoint Log s Checkpoint log record q Contains:   DirtyPageTable and list of active transactions  For each active transaction, LastLSN, the LSN of the last log  record written by the transaction q Fixed position on disk notes LSN of last completed checkpoint log record s Dirty pages are not written out at checkpoint time  Instead, they are flushed out continuously, in the background s Checkpoint is thus very low overhead q can be done frequently Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 57. ARIES Recovery Algorithm ARIES recovery involves three passes s Analysis pass: Determines q Which transactions to undo q Which pages were dirty (disk version not up to date) at time of crash q RedoLSN: LSN from which redo should start s Redo pass: q Repeats history, redoing all actions from RedoLSN   RecLSN and PageLSNs are used to avoid redoing actions already  reflected on page  s Undo pass: q Rolls back all incomplete transactions  Transactions whose abort was complete earlier are not undone – Key idea: no need to undo these transactions: earlier undo  actions were logged, and are redone as required Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 58. Aries Recovery: 3 Passes s Analysis, redo and undo passes s Analysis determines where redo should start s Undo has to go back till start of earliest incomplete transaction Last checkpoint End of Log Time Log Analysis pass Redo pass Undo pass Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 59. ARIES Recovery: Analysis Analysis pass s Starts from last complete checkpoint log record q Reads DirtyPageTable from log record q Sets RedoLSN = min of RecLSNs of all pages in DirtyPageTable  In case no pages are dirty, RedoLSN = checkpoint record’s  LSN q Sets undo­list = list of transactions in checkpoint log record q Reads LSN of last log record for each transaction in undo­list from  checkpoint log record s Scans forward from checkpoint s .. Cont. on next page … Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 60. ARIES Recovery: Analysis (Cont.) Analysis pass (cont.) s Scans forward from checkpoint q If any log record found for transaction not in undo­list, adds  transaction to undo­list q Whenever an update log record is found  If page is not in DirtyPageTable, it is added with RecLSN set to  LSN of the update log record q If transaction end log record found, delete transaction from undo­list q Keeps track of last log record for each transaction in undo­list  May be needed for later undo s At end of analysis pass: q RedoLSN determines where to start redo pass q RecLSN for each page in DirtyPageTable used to minimize redo work q All transactions in undo­list need to be rolled back Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 61. ARIES Redo Pass Redo Pass: Repeats history by replaying every action not already  reflected in the page on disk, as follows: s Scans forward from RedoLSN.  Whenever an update log record is  found: 1. If the page is not in DirtyPageTable or the LSN of the log record is  less than the RecLSN of the page in DirtyPageTable, then skip  the log record 2. Otherwise fetch the page from disk.  If the PageLSN of the page  fetched from disk is less than the LSN of the log record, redo the  log record NOTE: if either test is negative the effects of the log record have  already appeared on the page.  First test avoids even fetching the  page from disk! Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 62. ARIES Undo Actions s When an undo is performed for an update log record q Generate a CLR containing the undo action performed (actions  performed during undo are logged physicaly or physiologically).   CLR for   record n noted as n’ in figure below q Set UndoNextLSN of the CLR to the PrevLSN value of the update log  record  Arrows indicate UndoNextLSN value s ARIES supports partial rollback q Used e.g. to handle deadlocks by rolling back just enough to release  reqd. locks q Figure indicates forward actions after partial rollbacks   records 3 and 4 initially, later 5 and 6, then full rollback 1 2 3 4 4' 3' 5 6 6' 5' 2' 1' Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 63. ARIES: Undo Pass Undo pass: s Performs backward scan on log undoing all transaction in undo­list q Backward scan optimized by skipping unneeded log records as follows:  Next LSN to be undone for each transaction set to LSN of last log  record for transaction found by analysis pass.  At each step pick largest of these LSNs to undo, skip back to it and  undo it   After undoing a log record – For ordinary log records, set next LSN to be undone for  transaction to PrevLSN noted in the log record – For compensation log records (CLRs) set next LSN to be undo to  UndoNextLSN noted in the log record » All intervening records are skipped since they would have  been undone already s Undos performed as described earlier Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 64. Other ARIES Features s Recovery Independence q Pages can be recovered independently of others  E.g. if some disk pages fail they can be recovered from a backup  while other pages are being used s Savepoints: q Transactions can record savepoints and roll back to a savepoint  Useful for complex transactions  Also used to rollback just enough to release locks on deadlock Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 65. Other ARIES Features (Cont.) s Fine­grained locking: q Index concurrency algorithms that permit tuple level locking on  indices can be used  These require logical undo, rather than physical undo, as in  advanced recovery algorithm s Recovery optimizations:  For example: q Dirty page table can be used to prefetch pages during redo q Out of order redo is possible:   redo can be postponed on a page being fetched from disk,  and  performed when page is fetched.    Meanwhile other log records can continue to be processed Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 66. Remote Backup Systems Database System Concepts ©Silberschatz, Korth and Sudarshan See www.db­book.com for conditions on re­use 
  • 67. Remote Backup Systems s Remote backup systems provide high availability by allowing transaction  processing to continue even if the primary site is destroyed. Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 68. Remote Backup Systems (Cont.) s Detection of failure: Backup site must detect when primary site has  failed  q to distinguish primary site failure from link failure maintain several  communication links between the primary and the remote backup. q Heart­beat messages s Transfer of control:  q To take over control backup site first perform recovery using its copy  of the database and all the long records it has received from the  primary.   Thus, completed transactions are redone and incomplete  transactions are rolled back. q When the backup site takes over processing it becomes the new  primary q To transfer control back to old primary when it recovers, old primary  must receive redo logs from the old backup and apply all updates  locally. Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 69. Remote Backup Systems (Cont.) s Time to recover: To reduce delay in takeover, backup site periodically  proceses the redo log records (in effect, performing recovery from  previous database state), performs a checkpoint, and can then delete  earlier parts of the log.  s Hot­Spare configuration permits very fast takeover: q Backup continually processes redo log record as they arrive,  applying the updates locally. q When failure of the primary is detected the backup rolls back  incomplete transactions, and is ready to  process new transactions. s Alternative to remote backup: distributed database with replicated data q Remote backup is faster and cheaper, but less tolerant to failure   more on this in Chapter 19 Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 70. Remote Backup Systems (Cont.) s Ensure durability of updates by delaying transaction commit until update is  logged at backup; avoid this delay by permitting lower degrees of durability. s One­safe: commit as soon as transaction’s commit log record is written at  primary q Problem: updates may not arrive at backup before it takes over. s Two­very­safe: commit when transaction’s commit log record is written at  primary and backup q Reduces availability since transactions cannot commit if either site fails. s Two­safe: proceed as in two­very­safe if both primary and backup are  active. If only the primary is active, the transaction commits as soon as is  commit log record is written at the primary.  q Better availability than two­very­safe; avoids problem of lost  transactions in one­safe.  Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 71. End of Chapter Database System Concepts ©Silberschatz, Korth and Sudarshan See www.db­book.com for conditions on re­use 
  • 72. Shadow Paging s Shadow paging is an alternative to log­based recovery; this scheme is  useful if  transactions execute serially s Idea: maintain two page tables during the lifetime of a transaction –the  current page table, and the shadow page table s Store the shadow page table in nonvolatile storage, such that state of the  database prior to transaction execution may be recovered.  q Shadow page table is never modified during execution s To start with, both the page tables are identical. Only current page table is  used for data item accesses during execution of the transaction. s Whenever any page is about to be written for the first time q A copy of this page is made onto an unused page.  q The current page table is then made to point to the copy q The update is performed on the copy Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 73. Sample Page Table Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 74. Example of Shadow Paging Shadow and current page tables after write to page 4  Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 75. Shadow Paging (Cont.) s To commit a transaction :   1.  Flush all modified pages in main memory to disk   2.  Output current page table to disk   3.  Make the current page table the new shadow page table, as follows: q keep a pointer to the shadow page table at a fixed (known) location  on disk. q to make the current page table the new shadow page table, simply  update the pointer to point to current page table on disk s Once pointer to shadow page table has been written, transaction is  committed. s No recovery is needed after a crash — new transactions can start right  away, using the shadow page table. s Pages not pointed to from current/shadow page table should be freed  (garbage collected). Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 76. Show Paging (Cont.) s Advantages of shadow­paging over log­based schemes q no overhead of writing log records q recovery is trivial s Disadvantages : q Copying the entire page table is very expensive  Can be reduced by using a page table structured like a B+­tree – No need to copy entire tree, only need to copy paths in the tree  that lead to updated leaf nodes q Commit overhead is high even with above extension  Need to flush every updated page, and page table q Data gets fragmented (related pages get separated on disk) q After every transaction completion, the database pages containing old  versions of modified data need to be garbage collected  q Hard to extend algorithm to allow transactions to run concurrently  Easier to extend log based schemes Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 77. Block Storage Operations Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 78. Portion of the Database Log Corresponding to  T0 and T1 Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 79. State of the Log and Database Corresponding  to T0 and T1 Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 80. Portion of the System Log Corresponding to  T0 and T1 Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan
  • 81. State of System Log and Database  Corresponding to T0 and T1 Database System Concepts, 5th Ed. 17.<number> ©Silberschatz, Korth and Sudarshan