frank
frank

Reputation: 141

Why does database can use logical log for undo operation without considering inconsistency

For a single database operation, it may affect multiple pages. For example, an insert operation may result in page split. As a result, databases don't use logical log for redo operation because of the inconsistency consideration (A operation affect two pages, only one page is flushed into data when system crashed). They always use physiological log or physical log for redo operation. But in ARIES algorithm or some databases (eg . mysql), they use logical log for undo, which operation may affect multiple pages. Why they can do this? How do they guarantee the rollback correctness when only some pages affected by the undo operation are flushed into the disk and the system crashed again?

Upvotes: 4

Views: 1469

Answers (1)

yifanwu
yifanwu

Reputation: 1655

Aries logs the recovery operations as well, so the issue of a crash during recovery (your last question) is orthogonal to the question of logical logging for undo. The fact that an operation may affect multiple pages doesn't inherently cause consistency issues.

I think you could in theory use logical log for redo as well ("The redo and the undo operations can be performed logically" in original Aries paper), but the biggest plus for physical is that it's idempotent. The UNDO protocol ensures that an operation is not executed more than once.

There are a few advantages to logical logs (compared to physical):

  • saves space
  • "Being able to perform logical undos allows higher levels of concurrency to be supported"

Upvotes: 3

Related Questions