“This is the 18th day of my participation in the Gwen Challenge in November. Check out the details: The Last Gwen Challenge in 2021”

Redo Log flush rules:

In the MySQL engine, redo logs are a feature used to ensure atomicity and persistence of transactions.

Today we’re going to take a look at writing redo log buffers to redo log files,

In general, there are three phases for a common transaction commit:

  • Transaction ready commit:

  • During the transaction commit:

  • Transaction committed:

During a transaction commit, the redo log buffer is forcibly written to the redo log file, usually with a call to the operating system’s fsync().

It will also pass through the operating system kernel space, OS buffer, because MySQL and log caching work in the operating system environment

Nature:

During the transaction commit, log cached data must be persisted to disk log files and passed through the operating system’s kernel-space cache, also known as the OS Buffer.

When a Redo log file is written to a disk from the user-space log buffer,

Need OS buffer for kernel space;

The log file does not use the O_DIRECT flag. If it has this flag, it can write data directly to disk without passing through the OS buffer kernel space.

Matters needing attention:

For redo logs to remain persistent, the log cache must be written to disk. Generally, the redo buffer detects the amount of current data. If the redo buffer exceeds half of the current data, a flush is triggered.

When there is a checkpoint in the transaction, it represents the location of the LSN where the disk log is written, and the logical serial number of the log;

Redo log Redo buffer to redo log file persistence

Persistent from log cache to kernel space OS buffer –>file;