Class RecoveryInfo


  • public class RecoveryInfo
    extends java.lang.Object
    This class holds information necessary for the WALManager to perform recovery processing, such as the LSNs to scan for redo/undo processing, and the set of incomplete transactions.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      LogSequenceNumber firstLSN
      This is the log sequence number to start recovery processing from.
      java.util.HashMap<java.lang.Integer,​LogSequenceNumber> incompleteTxns
      This is the set of incomplete transactions found during recovery processing, along with the last log sequence number seen for each transaction.
      int maxTransactionID
      This is the maximum transaction ID seen in the write-ahead logs.
      LogSequenceNumber nextLSN
      This is the "next LSN", one past the last valid log sequence number found in the write-ahead logs.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      LogSequenceNumber getLastLSN​(int transactionID)
      This helper method returns the last log sequence number seen for the specified transaction.
      boolean hasIncompleteTxns()
      Returns true if there are any incomplete transactions, or false if all transactions are completed.
      boolean isTxnComplete​(int transactionID)
      Returns true if the specified transaction is complete, or false if it appears in the set of incomplete transactions.
      void recordTxnCompleted​(int transactionID)
      This helper function records that the specified transaction is completed in the write-ahead log.
      void updateInfo​(int transactionID, LogSequenceNumber lsn)
      This helper method updates the recovery information with the specified transaction ID and log sequence number.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • firstLSN

        public LogSequenceNumber firstLSN
        This is the log sequence number to start recovery processing from.
      • nextLSN

        public LogSequenceNumber nextLSN
        This is the "next LSN", one past the last valid log sequence number found in the write-ahead logs.
      • maxTransactionID

        public int maxTransactionID
        This is the maximum transaction ID seen in the write-ahead logs. The next transaction ID used by the database system will be one more than this value.
      • incompleteTxns

        public java.util.HashMap<java.lang.Integer,​LogSequenceNumber> incompleteTxns
        This is the set of incomplete transactions found during recovery processing, along with the last log sequence number seen for each transaction.
    • Method Detail

      • updateInfo

        public void updateInfo​(int transactionID,
                               LogSequenceNumber lsn)
        This helper method updates the recovery information with the specified transaction ID and log sequence number. The requirement is that this method is only used during redo processing; we expect that log sequence numbers are monotonically increasing.
        Parameters:
        transactionID - the ID of the transaction that appears in the current write-ahead log record
        lsn - the log sequence number of the current write-ahead log record
      • getLastLSN

        public LogSequenceNumber getLastLSN​(int transactionID)
        This helper method returns the last log sequence number seen for the specified transaction. It is used during undo processing to allow subsequent WAL records to refer to the earlier WAL records that appear for the transaction.
        Parameters:
        transactionID - the ID of the transaction to get the most recent LSN for
        Returns:
        the last log sequence number seen for the specified transaction
      • recordTxnCompleted

        public void recordTxnCompleted​(int transactionID)
        This helper function records that the specified transaction is completed in the write-ahead log. Specifically, the transaction is removed from the set of incomplete transactions.
        Parameters:
        transactionID - the transaction to record as completed
      • hasIncompleteTxns

        public boolean hasIncompleteTxns()
        Returns true if there are any incomplete transactions, or false if all transactions are completed.
        Returns:
        true if there are any incomplete transactions, or false if all transactions are completed.
      • isTxnComplete

        public boolean isTxnComplete​(int transactionID)
        Returns true if the specified transaction is complete, or false if it appears in the set of incomplete transactions.
        Parameters:
        transactionID - the transaction to check for completion status
        Returns:
        true if the transaction is complete, or false otherwise