The basic unit of database, OS, and disk reads and writes is block size, also known as (page size) block size.

Database blocks are generally 8K, 16K; OS blocks are generally 4K; The IO block size is smaller, and the Linux kernel requires the IO block size <= OS block size.

In addition to the IO block size, there is also the concept of the IO sector. The sector is the basic unit of physical operation on the disk. The IO block is the logical unit of operation on the disk.

So the relationship between block sizes is as follows:

DB block > OS block >= IO block > Disk block For example, DB takes MySQL as an example, OS takes Linux as an example:

DB block size

mysql> show variables like ‘innodb_page_size’;

| Variable_name | Value |

| innodb_page_size | 16384 |

1 row in set (0.01sec)

OS block size

IO block size

Sector size

Sector size (logical/physical): 512 bytes / 512 bytes

DB page=4OS page=16IO pages=32*sector size DB page=4OS page=16IO pages=32*sector size

Since any DB Page write will eventually be converted to a sector write, if there is an abnormal restart during the process of writing to disk, it may occur that a DB page only writes part of the sector to disk, resulting in a page break.

The page size of InnoDB is usually 16KB, and its data calibration is also calculated according to this 16KB, and the operation of writing data to disk is carried out in page unit. A partial page write is an example of a partial page write. When you write a partial page write to 4K of data, a partial page write is a partial page write. When you write a partial page write to 4K of data, you write a partial page write.

Mysql: partial page write: partial page write: partial page write: partial page write: partial page write: partial page write: partial page The page is corrupted. The transaction number to change the page cannot be found. It cannot be restored.

So there is no point in applying redo when the page is corrupted, and you cannot use redo to restore it because the original page of the game is corrupted and data loss occurs.

When InnoDB moves Dirty pages from the Buffer Pool to disk, it first moves Dirty pages (memcpy function) to InnoDB system tablespace (ibdata1) in an area. We call this area the Double Write Buffer (2MB in size, 1MB per write, 128 pages). After successfully writing to the D www.cungun.comouble write buffer, the second step copies the data to the corresponding location in the data file.

When a failure occurs during the second step, a partial page write problem occurs. When restoring a page, check whether the checksum is the same or not, then restore it directly from doublewrite

1) If writing to the doublewrite buffer fails, then the data will not be written to disk. InnoDB will load the disk raw data and compare it with the redo log, and rebrush it to the doublewrite buffer.

2) If the write to the doublewrite buffer succeeds, but the flush to disk fails, InnoDB will not recover through the transaction log, but will flush the doublewrite buffer directly.

mysql> show variables like ‘%double%’;

| Variable_name | Value |

| innodb_doublewrite | ON |

1 row in set (0.00 sec)

mysql> show status like ‘%innodb_dblw%’;

| Variable_name | Value |

| Innodb_dblwr_pages_written | 5951 |

| Innodb_dblwr_writes | 1383 |