HiveBrain v1.2.0
Get Started
← Back to all entries
patternMajor

Why must uncommitted transactions be undone in backwards order?

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
undonewhyordermustuncommittedbackwardstransactions

Problem

I have a database log where some transactions win (they are committed before crash) and some lose (not committed yet). We learned in class that the losers' actions have to be undone backwards.

Is there any reason for doing this backwards? Can anyone give a simple example of a log where forward undos would give wrong results?

Solution

Original transactions:

  • Insert record $r$.



  • Update some field $f$ of $r$.



Forward undo:

  • Delete record $r$.



  • Reverse the update to $r$ - oh wait, $r$ no longer exists! This causes an error.

Context

StackExchange Computer Science Q#60525, answer score: 36

Revisions (0)

No revisions yet.