Hello! Welcome back to our exploration of database recovery.
In our last lesson, we outlined the high-level architecture of ARIES, describing the purpose of its three recovery phases: Analysis, Redo, and Undo. We saw what each phase accomplishes to bring a crashed database back to a consistent state.
Today, we will zoom in on the critical data structures that power this entire process. This lesson focuses on the "bookkeeping" that makes ARIES's robust recovery possible. Your learning outcome is to explain the role of Log Sequence Numbers (LSNs), the dirty page table, and the transaction table in ARIES. Think of these as the navigation system for the recovery manager, allowing it to precisely track every change and the status of every transaction and page.
1. Log Sequence Numbers (LSNs): The DNA of Every Change
At the heart of the Write-Ahead Log (WAL) is the Log Sequence Number (LSN). You can think of an LSN as a unique, ever-increasing serial number assigned to every log record. It provides a strict ordering of all operations that have ever happened in the database.
Given your background in data structures, the most important LSN for chaining operations together is the prevLSN.
Lecture 20 Part 8: ARIES Logging
To start, let's watch a short segment from UC Berkeley's CS186 course. It explains the fundamental structure of an ARIES log record and highlights how the prevLSN field creates a backward linked list for each transaction's updates.
Watch the video from the beginning to 02:11. Focus on understanding the core fields of a log record: LSN, Transaction ID, and especially prevLSN.
As the video explained, the prevLSN allows the database to efficiently trace back the history of a single transaction, which is essential for the Undo phase.
While every log record has a primary LSN, the system also maintains several other important LSNs to track the state of pages and transactions. These are crucial for making recovery efficient.
Here is a summary of the most important LSNs used in ARIES:
| LSN Type | Where it's Stored | Purpose |
|---|---|---|
LSN |
In every log record | The unique, primary identifier for a log record. |
prevLSN |
In a transaction's log records | Points to the previous log record from the same transaction, forming a backward linked list. |
pageLSN |
In the header of each data page | Stores the LSN of the most recent update applied to that page. Answers: "What version is this page?" |
lastLSN |
In the Transaction Table | The LSN of the most recent log record written by a transaction. Answers: "What did this txn do last?" |
recLSN |
In the Dirty Page Table | The LSN of the first log record that dirtied a page. Answers: "When did this page first become dirty?" |
Understanding the distinction between pageLSN and recLSN is particularly important, as we'll see next.
2. The Control Center: Transaction and Dirty Page Tables
During normal operation, ARIES maintains two critical in-memory data structures to avoid having to scan the entire log just to know what's going on. These are the Active Transaction Table (ATT) and the Dirty Page Table (DPT). They are essential for the Analysis phase and for directing the Redo and Undo phases.
Lecture 20 Part 8: ARIES Logging
The same video from CS186 provides an excellent explanation of the ATT and DPT. It details what each table stores and why that information is critical for recovery.
Watch from 02:11 to 05:03. Pay close attention to: The fields in the Transaction Table (transactionId, status, lastLSN). The fields in the Dirty Page Table (pageId, recLSN). The definition of recLSN as the LSN of the first action that dirtied the page since it was brought into memory.
Let's break down what you just saw:
Active Transaction Table (ATT)
- What it tracks: All transactions that are currently running, committing, or in the process of being undone.
- Key Information:
transactionId: The unique ID of the transaction.status: The current state of the transaction (e.g.,Running,Committing,Undo).lastLSN: The LSN of the most recent log record for this transaction. This serves as the head of the linked list that the Undo phase will follow backward using theprevLSNpointers.
Dirty Page Table (DPT)
- What it tracks: All pages in the buffer pool that have been modified but not yet flushed to disk.
- Key Information:
pageId: The unique ID of the dirty page.recLSN(Recovery LSN): The LSN of the first log record that caused this page to become dirty since it was last read from disk. The Redo phase starts from the minimumrecLSNin this table, because that represents the oldest possible change that might be missing from disk.
The image below visually connects these concepts. It shows how specific log records populate the lastLSN in the Transaction Table and the recLSN in the Dirty Page Table.

Test your understanding!
Imagine a page P5 is read from disk into the buffer pool. It is then modified by a transaction, generating log record LSN 250. A short time later, another transaction modifies P5, generating log record LSN 265.
- What is the
recLSNfor pageP5in the Dirty Page Table? - What is the
pageLSNstored in the header of pageP5in the buffer pool?
Show answer
- The
recLSNforP5is 250. TherecLSNis set by the first log record that makes the page dirty after it enters the buffer pool and is not updated on subsequent writes. - The
pageLSNforP5is 265. ThepageLSNalways reflects the LSN of the most recent update to the page.
3. Seeing it in Action: A Logging Scenario
Now that we know the individual components, let's watch them work together during a normal execution sequence. This will help solidify how and when the tables and LSNs are updated.
ARIES Overview, Types of Log Records, ARIES Helper Structures
This video from Prof. Dr. Jens Dittrich provides a step-by-step walkthrough of a logging scenario. It's a great practical demonstration of how the log, pages, transaction table, and dirty page table evolve as transactions execute.
Watch the segment from 17:17 to 22:56. As you watch, trace the following: When an update occurs, how is the pageLSN on the data page updated? How does the lastLSN for a transaction in the transaction table change with each new update? Notice what happens to the recLSN in the dirty page table when a second transaction updates a page that is already dirty. Does it change?
This dynamic view shows that these tables are not static; they are constantly being updated to reflect the current state of the database engine. This live bookkeeping is what allows ARIES to perform a fast and accurate recovery after a crash.
Conclusion
In this lesson, we dissected the core data structures that underpin the ARIES recovery protocol. We moved from the high-level "what" of the three phases to the low-level "how" of tracking changes.
Key Takeaways:
- Log Sequence Numbers (LSNs) are the atomic unit of logging, providing a unique, ordered identifier for every change. Different types like
pageLSN,lastLSN, andrecLSNhelp track the state of pages and transactions. - The Transaction Table (ATT) acts as a directory of all active transactions, with
lastLSNproviding the entry point for rolling back a transaction's work. - The Dirty Page Table (DPT) keeps a list of all modified pages in memory, with
recLSNmarking the starting point in the log from which history may need to be repeated. - Together, these structures provide the ARIES recovery manager with all the information it needs to analyze a crash, redo history, and undo the work of incomplete transactions.
Preview of the Next Lesson
You now understand the map (the log) and the key landmarks (ATT and DPT). In our next lesson, we will put this knowledge to practical use. We will simulate a crash and then manually perform the Analysis phase of ARIES. You will scan a sample log to reconstruct the ATT and DPT, determining exactly which transactions were losers and which pages were dirty at the moment of failure.