Skip to content
tezvyn:
Menu

ARIES Recovery Algorithm

Source: Wikipedia: Algorithms for Recovery and Isolation Exploiting SemanticsHardHow cards are made

ARIES is a widely-used database recovery algorithm, found in systems like IBM Db2 and SQL Server. It enables high performance by supporting a 'no-force, steal' policy, ensuring data integrity after a crash. The main footgun is not understanding this policy.

Why it exists

ARIES was created to provide fast, reliable crash recovery for high-performance databases. Common performance-enhancing memory management policies, like 'steal' and 'no-force', create complex failure scenarios. ARIES provides a formal method to correctly restore a consistent database state in this environment.

The mental model

Think of ARIES as a meticulous accountant for your database. It uses a write-ahead log (a ledger) to record every single change before it happens. After a crash, it first replays the entire ledger to restore the state exactly as it was, then it carefully reverses any transactions that weren't finalized, logging each reversal to prevent errors if it's interrupted again.

How it works

The algorithm is built on three core ideas. First is Write-Ahead Logging (WAL), where every change is written to a log on stable storage before the corresponding database page is modified. Second is repeating history during recovery, where logged operations are reapplied to restore the database to its state at the time of the crash. Third is logging undos, where actions taken to roll back a transaction are themselves logged in special records (CLRs), preventing repeated work if recovery is interrupted.

The recovery process itself has three phases: Analysis, which scans the log to identify dirty pages and active transactions at the time of the crash. Redo, which re-applies all logged changes since the last checkpoint to bring the database up to date. And Undo, which rolls back all incomplete ('loser') transactions from last to first, using the CLRs to ensure idempotency.

When to use it

ARIES is the standard for transactional databases that need high throughput. It is specifically designed for systems using a 'steal/no-force' buffer management policy. 'Steal' allows uncommitted changes to be written to disk to free memory, and 'no-force' avoids flushing committed changes to disk immediately. This combination boosts performance but requires a robust recovery algorithm like ARIES.

When not to use it

The complexity of ARIES is overkill for simpler storage systems or databases that can afford stricter, less performant policies like 'no-steal' (uncommitted data is never written to disk) or 'force' (all committed data is immediately written to disk). In these cases, a simpler recovery mechanism is sufficient.

One canonical example

A user updates their shipping address. The database starts a transaction, modifies the data in a memory buffer, and writes the change to the log file on disk. To free up memory, the buffer manager writes this dirty page to disk before the transaction commits ('steal'). The system then crashes. On restart, ARIES's Redo phase re-applies the logged change. Then, the Undo phase identifies the transaction as a 'loser' (it never committed) and rolls back the address change, restoring the database to a consistent state.

Interview question

What core problem does ARIES primarily address in databases using a 'steal/no-force' buffer management policy?

  • a.It prevents any uncommitted data from being written to stable storage before a transaction commits.
  • b.It reduces the overall size of the transaction log by only recording final committed states.
  • c.It guarantees that all committed transactions are immediately written to disk, simplifying crash recovery.
  • d.It ensures data consistency by handling both uncommitted changes written to disk and committed changes not yet flushed.Correct
Why?

ARIES is specifically designed to manage the complexities of 'steal' (uncommitted data written to disk) and 'no-force' (committed data not immediately flushed), ensuring data consistency after a crash. Option A describes a 'no-steal' policy, which ARIES is designed to work without, not implement.

Just read this? Test yourself on what you have been reading.

Read the original → en.wikipedia.org

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on databases — each one lists the topics its interview covers.

See open roles