1220 database data_error ai_generated partial

ERROR 1220 (HY000): Error when executing command 'SHOW BINARY LOGS': binary log file 'mysql-bin.000123' is corrupted

ID: database/mysql-binary-log-corruption

Also available as: JSON · Markdown · 中文
72%Fix Rate
84%Confidence
1Evidence
2024-11-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
MySQL 8.0 active — — —
MySQL 8.4 active — — —
MySQL 9.0 active — — —
MariaDB 10.11 active — — —
MariaDB 11.4 active — — —

Root Cause

MySQL binary log file is corrupted due to disk failure, unexpected shutdown, or incomplete write, preventing replication or log inspection.

generic

中文

MySQL二进制日志文件因磁盘故障、意外关闭或不完整写入而损坏,阻止了复制或日志检查。

Official Documentation

https://dev.mysql.com/doc/refman/8.0/en/binary-log.html

Workarounds

  1. 70% success Skip the corrupted binary log file on the replica by setting the next log position. Example: STOP SLAVE; CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000124', MASTER_LOG_POS=4; START SLAVE;
    Skip the corrupted binary log file on the replica by setting the next log position. Example: STOP SLAVE; CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000124', MASTER_LOG_POS=4; START SLAVE;
  2. 75% success If the corruption is isolated, use mysqlbinlog to extract events up to the corruption point: mysqlbinlog --stop-position=123456 mysql-bin.000123 > partial.sql; then apply the partial log to the replica.
    If the corruption is isolated, use mysqlbinlog to extract events up to the corruption point: mysqlbinlog --stop-position=123456 mysql-bin.000123 > partial.sql; then apply the partial log to the replica.
  3. 80% success Purge the corrupted binary log file after ensuring all replicas have caught up: PURGE BINARY LOGS TO 'mysql-bin.000124'; Then reset the master log: RESET MASTER;
    Purge the corrupted binary log file after ensuring all replicas have caught up: PURGE BINARY LOGS TO 'mysql-bin.000124'; Then reset the master log: RESET MASTER;

中文步骤

  1. Skip the corrupted binary log file on the replica by setting the next log position. Example: STOP SLAVE; CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000124', MASTER_LOG_POS=4; START SLAVE;
  2. If the corruption is isolated, use mysqlbinlog to extract events up to the corruption point: mysqlbinlog --stop-position=123456 mysql-bin.000123 > partial.sql; then apply the partial log to the replica.
  3. Purge the corrupted binary log file after ensuring all replicas have caught up: PURGE BINARY LOGS TO 'mysql-bin.000124'; Then reset the master log: RESET MASTER;

Dead Ends

Common approaches that don't work:

  1. Delete all binary log files and restart MySQL. 90% fail

    This breaks replication if replicas rely on those logs; it also removes forensic evidence. Use PURGE BINARY LOGS instead.

  2. Ignore the corrupted log and continue without fixing replication. 95% fail

    Replication will stall at the corrupted log file; the replica will not apply further changes until the issue is resolved.