Why does XtraBackup tell me my MySQL database is corrupt?

This may be caused by a few different things.

  • You are running an old xtrabackup version which has a bug that may flag for corruption in the data files when there is none, update to the newest xtrabackup version for your mysql version.

  • There is corruption in the secondary indexes in a table

If you're able to perform a mysqldump of the tables the data should be intact and you need to either run optimize table or rebuild the tables. Identify ibd file corruption by checking each ibd file with innochecksum and use the pt-online-schema-schema-change application to rebuild the tables

pt-online-schema-change --dry-run --alter="ENGINE=INNODB" \
    --user=your_username --ask-pass \
    D=databasename,t=tablename

Replace the --dry-run with --execute when you want to perform the task.

  • Could be caused by encryption or compression set to the table

Optimize table: https://dev.mysql.com/doc/refman/8.0/en/optimize-table.html

Innochecksum: https://www.percona.com/blog/2015/03/16/deep-dive-mysqls-innochecksum-tool/

pt-online-schema-change: https://www.percona.com/doc/percona-toolkit/LATEST/pt-online-schema-change.html