Characteristics of transactions

  • atomic
  • consistency
  • Isolation,
  • persistence

Transaction implementation

Transaction atomicity, persistence, and consistency are implemented by redo logs and undo logs. Redo logs are used to ensure atomicity and persistence of transactions. Undo log is used to ensure transaction consistency.

redo log

Redo log commits page operations to a particular version, while Undo log rolls back operations to a particular version. Redo log is a physical log that records physical operations to a page, and Undo log is a logical log that records on a per-row basis

When a transaction commits, all logs of the transaction must be written to the redo log for persistence to ensure the persistence of the transaction.

undo log

Undo log, in fact, writes a reverse operation delete during the insert execution, but does not restore the previous state. For example, undo log records the INSERT during the DELETE rollback, but the space occupied by delete actually changes. In addition, the database still logs the redo log to protect the undo log

Binary log

Binary logs are logical logs that record SQL statements. They are mysql database logs. Redo and undo logs are innoDB-level logs that are used for master/slave replication