Prev: logging-protocols–schemes Next: introduction-to-distributed-databases
Aries stands for Algorithms for Recovery and Isolation Exploiting Semantics. Developed by IBM in the 90s.
Main ideas:
To implement this, the DBMS’s log record format needs additional information. Every log includes a globally unique log sequence number (LSN). Components in the system keep track of LSNs that pertain to them:
When a transaction goes to commit, the DBMS writes
COMMIT
to the log. Then the DBMS flushes all records up to
and including the transaction’s COMMIT
to disk.
Once the COMMIT
record is safely stored on disk, the
DBMS returns an acknowledgement to the application that the transaction
has committed. At some other point, the DBMS will write a
TXN-END
record for internal bookkeeping. It does not need
to be flushed immediately.
Aborting a transaction requires log records to have a pointer to the previous LSN. This points to the previous LSN for the transaction. The DBMS makes a linked list of LSNs to make it easier to walk through the log to find its records.
As well, aborts require another record called the compensation log record (CLR). A CLR describes the actions taken to undo the actions of a previous update record.
To abort, the DBMS appends an ABORT
record to the log
buffer in-memory. It then undoes the transaction’s updates in reverse
order to remove their effects from the database. For each update, the
DBMS creates CLR entries in the log and restores old values. Afterwards,
the DBMS writes a TXN-END
log record.
The DBMS makes checkpoints every once in a while, where it writes dirty pages in the buffer pool to disk. This keeps the size of the WAL bounded.
There are either blocking or non-blocking ways to take checkpoints.
The DBMS halts when it takes a checkpoint, to create a consistent snapshot. That is:
We can do better without stopping active transactions.
We use some extra metadata to do this.
Active Transaction Table (ATT): The ATT represents the state of transactions that are actively running in the DBMS. A transaction’s entry is removed after the DBMS completes the commit/abort process for that transaction. For each transaction, the ATT contains:
Dirty Page Table (DPT): The DPT contains information about the pages in the buffer pool that were modified by uncommitted transactions. There is one entry per dirty page containing the recLSN (the LSN of log records that caused the page to be dirty)
A fuzzy checkpoint is where the DBMS allows other transactions to continue to run. ARIES does this. The DBMS uses additional log records to track checkpoint boundaries:
The ARIES protocol is comprised of three phases. On startup or crash, the DBMS executes the following:
TXN-END
, remove it from the
ATT.UPDATE
records, if P
is not in the
DPT, add it. Then, set P
’s recLSN to the log record’s
LSN.This phase is to reconstruct state at the moment of the crash.
Reapplies all updates, and redoes CLRs
. The DBMS scans
forward from the log record containing the smallest recLSN in the DPT.
For each update log, the DBMS reapplies the update unless:
To redo an action, the DBMS reapplies the change in the log record and sets the affected page’s pageLSN to that log record’s LSN.
At the end of this phase, write TXN-END
with status
COMMIT and removes them from the ATT.
Finally, the DBMS has to reverse all transactions that were active at
the time of the crash. These are transactions with UNDO
status in the ATT after the Analysis phase.
The DBMS processes transactions in reverse LSN order, and as it reverses the updates of a transaction, the DBMS writes a CLR entry to the log for each modification.
Once the last transaction has been aborted, the DBMS flushes out the log and is ready to start processing new transactions.
Prev: logging-protocols–schemes Next: introduction-to-distributed-databases