In this article we will take a look at redo log, undo log, and bin log

The title The url
Standalone storage engine to mysql thinking a Blog.csdn.net/xk4848123/a…
Standalone storage engine to mysql thinking two Blog.csdn.net/xk4848123/a…
Standalone storage engine to mysql thinking three Blog.csdn.net/xk4848123/a…

redo log

Re for redo, do for redo, which is literally a redo log, which is actually a redo log. The redo log is used during database restart and recovery. Because of its physical log nature, the recovery rate is much faster than that of logical logs.

Write Ahead Log policy Write-ahead Log (WAL Write Ahead Log) : Modifications to data files (which are carriers for tables and indexes) must only occur after these modifications have been logged, that is, after logging describing these changes has been flushed into permanent storage this is a D (Durability) requirement in transaction ACID.

2.CheckPoint technology and Functions a. Shorten the database recovery time When the database is down, the database does not need to redo all the logs because the pages before CheckPoint have been flushed back to disk. Only the redo logs after CheckPoint are recovered, shortening the recovery time by b. When the buffer pool is insufficient, flush dirty pages to disk When the cache pool is insufficient, the LRU algorithm overflows the least recently used pages. If the pages are dirty, it forces CheckPoint to flush the dirty pages back to disk C. When the redo log is unavailable, the dirty page refresh is unavailable because the redo log is designed to be recycled. The portions of the redo log that can be reused are those that are not needed when a database is being restored. If the redo log is still available, CheckPoint is forced. D. heckPoint will flush dirty pages from the cache pool back to disk. 3.LSN (Log Sequence Number) LSN is used to mark the version. CheckPoint also has LSN CheckPoint technology compares data pages with the LSN (version) of redo logs to restore data

undo log

1.Undo Log ensures atomicity of transactions. For example, when the database goes DOWN, a transaction is being processed. When the database is restarted, a rollback is performed based on the log to restore the changes from the uncommitted transaction to the state before the transaction began. In crash-recovery mode, all transactions that have been prepared but are not committed will be rolled back using undo log. 2. In InnoDB engine, use Undo Log to implement MVCC. We have already covered MVCC in Thought 2, but it should be added that each row of the table has an implicit column, which is the Undo Log PTR. In this way, snapshots of the corresponding version can be found at the RR isolation level to ensure repeatability.

Binlog and primary/secondary replication

What is the binlog

Binlog is a logical log of mysql, which records logical SQL changes.

A master-slave replication

This section describes the mysql primary/secondary asynchronous replication process. Master Enables the bin-log function. Log files are used to record read, write, add, or delete data from the database. Three threads are required: the master IO thread and the SLAVE IO thread. Position after position. The MASTER server receives the log request message from the SLAVE I/O thread. The I/O thread returns the bin-log content and position to the slave I/O thread. The slave server receives bin-lo logs, writes bin-log logs to relay logs, and creates a master.info file that records the master IP user name and password master bin-log name. Bin – log position. SQL threads are enabled on the slave side to monitor whether the relay-log content is updated in real time. SQL statements in the files are parsed and executed in the slave database. So what is semi-synchronous replication and which version started supporting it?