Skip to main content

execute

Function execute 

Source
pub fn execute(
    opts: &ChecksumOptions,
    writer: &mut dyn Write,
) -> Result<(), IdbError>
Expand description

Validate page checksums for every page in an InnoDB tablespace.

Iterates over all pages and validates the stored checksum (bytes 0-3 of the FIL header) against two algorithms: CRC-32C (MySQL 5.7.7+), which XORs two independent CRC-32C values computed over bytes [4..26) and [38..page_size-8); and legacy InnoDB, which uses ut_fold_ulint_pair with u32 wrapping arithmetic over the same two byte ranges. A page is considered valid if either algorithm matches the stored value.

Additionally checks LSN consistency: the low 32 bits of the header LSN (bytes 16-23) must match the LSN value in the 8-byte FIL trailer at the end of the page. All-zero pages are counted as empty and skipped entirely.

When the tablespace has more than one page, all page data is read into memory and checksums are validated in parallel using rayon. Results are collected in page order for deterministic output.

Prints a summary with total, empty, valid, and invalid page counts. In --verbose mode, every non-empty page is printed with its algorithm, stored and calculated checksum values, and LSN status. The process exits with code 1 if any page has an invalid checksum, making this suitable for scripted integrity checks.

Note: When --streaming is combined with --json, the output uses NDJSON (one JSON object per line) rather than a single JSON document.