Definitioncore
Compensation log record
Also called CLR.
A redo-only log record written when an update is undone, which points to the next record to undo so rollback is never repeated.
A compensation log record (CLR) is the log record that a database writes when it undoes one update of a transaction. It holds the change that the undo made, as redo information only, and a pointer, the undoNextLSN, to the next record of the transaction that is still to be undone, so that a later rollback skips every update that an earlier, interrupted rollback already undid. A CLR is redone after a crash but never undone; it is a part of ARIES recovery that the plain undo/redo logging algorithm does not have, and savepoints use it for partial rollback. Unlike a checkpoint record, which copies the system's tables to make restart shorter, a CLR belongs to one transaction and describes one change to one page.
Definition
Let be an update record of transaction , with page , location in the page, before image and prevLSN . When undoes , during an abort, a partial rollback or the undo pass of restart, it appends a CLR with these fields:
| field | value |
|---|---|
| LSN | the next LSN of the log |
| type | CLR |
| txn id | |
| prevLSN | the lastLSN of , its newest record before |
| page id, location | the page and place that the undo changed, usually and |
| after image | the value that the undo wrote, usually |
| undoNextLSN | , the prevLSN of |
It then applies the change to the page and sets the pageLSN of the page to , as for any change. The undo of and the writing of follow the WAL rule like an update: the page with the undo goes to disk only after is stable.
The CLR has no before image, because it is never undone. To roll back , start at its newest record and repeat: if the record is an update, undo it and write a CLR; if it is a CLR, jump to its undoNextLSN; stop at LSN 0 (or, for a partial rollback, at the savepoint's LSN). Since each CLR points past the update it undid, the updates met on this walk are exactly those that no CLR has undone, newest first. The ARIES page proves this as its chain lemma.
If the undo is logical, the CLR can name a different page than . For example, after a B-tree page split moved the key that inserted, the undo deletes the key from its new page, and the CLR names that page. This is why a CLR records the undo action itself and not just a reference to .
Examples and non-examples
An interrupted rollback. Transaction writes updates , , (LSNs 1, 2, 3, with prevLSNs 0, 1, 2) and then aborts.
| LSN | record | prevLSN | undoNextLSN |
|---|---|---|---|
| 1 | update | 0 | |
| 2 | update | 1 | |
| 3 | update | 2 | |
| 4 | abort | 3 | |
| 5 | CLR for | 4 | 2 |
| 6 | CLR for | 5 | 1 |
The system crashes after LSN 6 is stable. Restart redoes LSNs 1 to 6, which puts the pages in their state at the crash: and undone, in place. The undo pass starts at LSN 6, a CLR, so it jumps to its undoNextLSN, 1, undoes , writes CLR 7 with undoNextLSN 0, and ends . Whatever the number of crashes during this rollback, gets at most three CLRs, one per update.
The same run without CLRs. Suppose the undo of and had been logged as ordinary update records and of , with before and after images. After the crash, is a loser with five updates, , and restart undoes all five, newest first: it first takes back the undo , putting back 's value, then , then , , . The final state is right, but the work and the log grow with every crash during rollback. Section 11 of the ARIES paper reports that in methods where such records are undone, the log written during repeated failures of restart can grow exponentially in the worst case, while in other methods it grows linearly; with CLRs it is bounded by one CLR per update.
A partial rollback. A savepoint records the LSN of the transaction's newest record when the savepoint was set. Rollback to it writes CLRs for the updates after , newest first, and stops when the next record to undo is at or before ; the last CLR has undoNextLSN equal to the prevLSN of the oldest undone update, which is at most . The transaction then goes on, and its later records chain back through the CLRs, so a later full rollback skips the undone part.
Non-example: an undo record. In an undo log or in undo logging, the record is written before the change and holds the old value so that the change can be undone. A CLR is written after an undo and describes the undo.
Non-example: the abort record. It marks the start of a rollback, changes no page, and carries no undoNextLSN.
Non-example: a CLR that is undone. A record that restart undoes like an update is not a CLR, even if it describes an undo. Undoing it puts the original change back for a moment, as the second example shows.
Related definitions
- The log sequence number page defines prevLSN and undoNextLSN, and the pageLSN that a CLR sets.
- ARIES recovery redoes CLRs in its redo pass and follows their undoNextLSN in its undo pass.
- A dummy CLR in ARIES ends a nested top action, such as a page split that must survive the rollback of its transaction: its undoNextLSN points before the action, so the undo pass jumps over it.
- A savepoint is the main user of partial rollback with CLRs.
- Logical logging is the case where the CLR's undo action differs from the inverse of a byte change.
- The fuzzy checkpoint copies each transaction's undoNext, which a CLR sets.
References
- C. Mohan, Don Haderle, Bruce Lindsay, Hamid Pirahesh and Peter Schwarz, ARIES, a transaction recovery method supporting fine-granularity locking and partial rollbacks using write-ahead logging, ACM Transactions on Database Systems 17(1), 1992, pages 94 to 162, Section 4.1, Log Records (CLRs hold only redo information, UndoNxtLSN), Section 5.2, Total or Partial Rollbacks (one CLR per undone record, Figure 3), and Section 11 (the log growth of other methods during repeated restart failures)
- Raghu Ramakrishnan and Johannes Gehrke, Database Management Systems, third edition, McGraw-Hill, 2003, Chapter 18, Crash Recovery (compensation log records and the undo phase)
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag 2XEK6A Edit this page History Report an error Markdown