In one sentence:

Redo_log: Redo log that guarantees transaction persistence for physical changes to data pages

Undo_log: Rollback log for the logical log of recorded rows to ensure atomicity of transactions

Bin_log: binary logs. Unlike redo logs, bin logs run on the server layer.

redo log

The redo log is a log of InnoDB storage engine layer (which means it runs on the Server layer). It is used to record changes in transaction operations. The redo log is recorded regardless of whether the transaction is committed or not. Redo log files are useful in the event of media failures, such as a database power failure. InnoDB storage engine uses redo log to restore data to the time before the power failure to ensure data integrity.

When an update statement is executed, InnoDB writes the update to the redo log, then updates the memory until the statement is complete, and then updates the contents of the redo log to disk at idle time or according to the specified update policy. Log first, then disk.

Circular linked list

The redo log cache is essentially a circular linked list that maintains read and write Pointers. When the Pointers meet, the buffer is slow, and the database stops executing updates and synchronizes the redo log to disk.

undo log

Holds a version of the data prior to the transaction, can be used for rollback, and can also provide multi-version concurrency control read (MVCC), that is, unlocked read. Then I will write an article introduction. MVCC.

Difference between undo log and redo log

Undo logs are not redo logs. They are actually redo logs:

  1. A redo log is usually a physical log that records physical changes to a data page, not changes to one or more rows. It is used to restore a physical data page after a commit (and only to the last commit location).
  2. Undo rolls back and forth rows to record a version. The undo log is a logical log that is recorded on a per-row basis.

bin log

Binlogs are logical logs that record the original logic of statements in binary format. Binlogs do not have the crash-safe capability

Crash-safe: If the database crashes at any time, records submitted before the database is restarted will not be lost

The difference between bin log and redo log

  • The redo log is innoDB, and the binlog is MySQL Server, so that the database can be consistent with other storage engines.
  • The redo log is a physical log that records updates to a data page. The binlog is the logical log that records the original logic of the update statement
  • Redo log is a circular log with a fixed size. A binlog is an appending file, which means that when a file is written to a certain size, it will be replaced by the next file.
  • Binlog can be used for data recovery, primary/secondary replication setup, and redo log for data recovery after an abnormal outage or media failure.

Please add the following text and link at the end of the article: This article is participating in the “Gold Digging Booklet free learning!” Event, click to view details of the event