A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Crash Recovery: Undo and Redo Logging

College Depth 96 in the knowledge graph I know this Set as goal
1topic build on this
398prerequisites beneath it
See this on the map →
ACID PropertiesWrite-Ahead Logging and Database Recovery+1 moreCheckpointing: Sharp and Fuzzy Checkpoints
recovery undo redo ARIES crash

Core Idea

Recovery algorithms use undo and redo logs to restore consistency after crashes. Undo logging records old values for backwards roll of uncommitted transactions; redo logging records new values for forwards replay of committed transactions. ARIES (Algorithm for Recovery and Isolation Exploiting Semantics) combines both: it redoes committed work, then undoes incomplete transactions. This approach minimizes recovery time and avoids re-executing long transactions.

Explainer

You already know from write-ahead logging that every change must be recorded in a log before it reaches the database on disk. The reason is simple: crashes can happen at any moment — between writing one page and the next, between logging a change and applying it, even mid-commit. The database must be able to reconstruct a consistent state from whatever survived on disk. The question is: what exactly should the log record, and how does recovery use those records?

Undo logging records the old value before each modification. If a transaction writes attribute A from value 5 to value 8, the undo log entry says "A was 5." The rule is that the actual database page must be written to disk before the transaction commits. If the system crashes before commit, recovery scans the log backward and restores every modified value to its old state — rolling back incomplete work. The advantage is straightforward recovery; the disadvantage is that every dirty page must be forced to disk before commit, which can be slow for transactions that touch many pages.

Redo logging takes the opposite approach: it records the new value. The undo log entry for the same operation would say "A becomes 8." Here the rule is reversed — the database pages must not be written to disk until after the transaction commits and the commit record is in the log. If the system crashes after commit but before pages were written, recovery replays the log forward, applying the new values. If the crash happens before commit, there is nothing to redo because the pages were never modified on disk. Redo logging allows lazy page writes (buffering changes in memory), but it means uncommitted changes never reach disk, which can limit buffer management flexibility.

ARIES (Algorithm for Recovery and Isolation Exploiting Semantics), used by most production databases, combines both strategies into undo/redo logging. Each log entry records both the old and new value. Pages can be flushed to disk at any time — before or after commit — giving the buffer manager maximum flexibility. Recovery proceeds in three phases: an analysis pass scans the log to determine which transactions were active at crash time and which pages might be dirty; a redo pass replays all logged changes from the most recent checkpoint forward to restore the database to its exact pre-crash state (including uncommitted changes that had been flushed); and an undo pass rolls back any transaction that was still active at crash time by applying the old values in reverse order. This "redo everything, then undo losers" approach is elegant because it separates two concerns: first bring the physical state up to date, then enforce transactional consistency on top of it.

Practice Questions 5 questions

Prerequisite Chain

Understanding ZeroThe Number ZeroCounting to FiveCounting to 10Counting to 20Counting a Set of Objects Up to 20Cardinality: The Last Number CountedMatching Numerals to QuantitiesSubitizing Small QuantitiesAddition Within 10Number Bonds to 10Addition Within 20Doubles and Near DoublesDoubles Facts Within 10Near Doubles Facts Within 20Mental Math Strategies for AdditionMental Math: Adding and Subtracting TensAddition Within 100Repeated Addition as MultiplicationMultiplication as Equal GroupsMultiplication: ArraysBasic Multiplication Facts (0s, 1s, 2s, 5s, 10s)Multiplication Facts Within 100Division as Equal SharingDivision as Grouping (Measurement Division)Division: Grouping (Repeated Subtraction) ModelDivision: Fair Sharing ModelDivision as Equal SharingDivision as GroupingBasic Division FactsDivision Facts Within 100Multiplication and Division Fact FamiliesRelationship Between Multiplication and DivisionDivision Facts as Inverse of MultiplicationRemainders and Quotients in DivisionDivision Word ProblemsMulti-Step Word ProblemsSolving Multi-Step Word ProblemsMultiplication Word ProblemsDivision Word ProblemsIntroduction to Long DivisionFactors and MultiplesPrime and Composite NumbersEquivalent FractionsRelating Fractions and DecimalsDecimal Place ValueIntegers and the Number LineComparing and Ordering IntegersAbsolute ValueAdding IntegersSubtracting IntegersMultiplying IntegersIntroduction to ExponentsOrder of OperationsInteger Order of OperationsVariable ExpressionsThe Distributive PropertyVariables and Expressions ReviewIntroduction to PolynomialsAdding and Subtracting PolynomialsMultiplying PolynomialsFactorialPermutationsCombinationsCounting Principles: Addition and Multiplication RulesIntroduction to Graph TheoryPropositional Logic FoundationsLogical EquivalencesBoolean AlgebraBoolean Type and Truth ValuesComparison Operators and Boolean TestsLogical Operators and Boolean AlgebraBoolean Algebra and Fundamental LawsLogic Gates FundamentalsImplementing Boolean Functions with GatesKarnaugh Map SimplificationCombinational Circuit DesignFlip-Flops and LatchesBinary Counters: Design and AnalysisBinary ArithmeticFixed-Point Number RepresentationTwo's Complement RepresentationOverflow and Underflow DetectionBinary Adders: Half-Adders and Full-AddersFull Adder and Carry PropagationCarry Lookahead Adder DesignHalf Adder Circuit DesignMultiplication Circuit DesignSequential Circuit DesignRegisters and Register FilesInstruction Set Architecture (ISA)Assembly Language BasicsMemory Organization and AddressingMemory HierarchyMemory Management FundamentalsBuffer Pool Management and Cache Replacement PoliciesCrash Recovery: Undo and Redo Logging

Longest path: 97 steps · 398 total prerequisite topics

Prerequisites (3)

Leads To (1)