Issue
The database crashes or reboots unexpectedly when running DDL operations, such as ALTER TABLE ... DROP FOREIGN KEY.
The error log contains assertion failures similar to:
InnoDB: Assertion failure in file .../btr0btr.cc line 204
InnoDB: Failing assertion: mach_read_from_4(seg_header + FSEG_HDR_SPACE) == spaceEnvironment
MariaDB Enterprise Server
Cause
The InnoDB data dictionary or tablespace metadata has become corrupted.
Resolution
To resolve the corruption, rebuild the InnoDB system tablespace by exporting the data, removing the corrupted system files, and restoring the data.
⚠️ Warning: This is a destructive process. Ensure you have a complete, verified backup of all databases before proceeding.
- Export all data, routines, and events using
mariadb-dump:mariadb-dump --all-databases --routines --events > /tmp/all_dbs.sql - Drop the affected databases. This step prevents conflicts and errors (such as "Table doesn't exist" or "Directory not empty") during the restore process.
- Stop the MariaDB service:
systemctl stop mariadb - Navigate to your MariaDB data directory and rename or remove the InnoDB system files:
ibdata1ib_logfile0ib_logfile1ibtmp1(if it exists)
Example:
mv ibdata1 ibdata1.bak
mv ib_logfile0 ib_logfile0.bak
mv ib_logfile1 ib_logfile1.bak
mv ibtmp1 ibtmp1.bak - Start the MariaDB service. The server will initialize a clean, uncorrupted data dictionary and fresh system tablespaces:
systemctl start mariadb - Restore the data from the dump file created in step 1:
mariadb < /tmp/all_dbs.sql