Simple understanding of redo log, undo log, binlog in MySQL

Redo log

Role: to
  ensure the durability of the transaction.
  To prevent dirty pages from being written to the disk at the point of failure, when restarting the mysql service, data recovery is performed according to the redo log, so call it redo

Undo log

Function:
  Save a version of the data before the transaction occurs, which can be used for rollback, and can provide multi-version concurrent control read (MVCC), that is, non-locking read

Binary log (binlog):

Function:
  1. Used for replication. In master-slave replication, the slave library uses the binlog on the master library for replay to achieve master-slave synchronization.
  2. It is used for point-in-time restoration of the database.

 

 

for example:

To change the age=66 of a piece of data to 77, in fact, many steps have been taken, and several logs have been generated.

  • Find this row of data from the disk and load it into the BufferPool,
  • At this time, update table set age=77 where id =1 in BufferPool,
  • And generate the corresponding redo log, which can be used for persistence when commit
  • At the same time generate binlog persistence,
  • Also generating the corresponding undo log is the reverse operation of redo, update table set age=66 where id =1, so that it can be used when rollback.

 

 

 

 

 

 

 

Guess you like

Origin blog.csdn.net/liuming690452074/article/details/113819900