ERROR database replication_error ai_generated true

ERROR 1236 (HY000): Could not find first log file name in binary log index file

ID: database/mysql-binlog-error

Also available as: JSON · Markdown
82%Fix Rate
85%Confidence
45Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
8 active

Root Cause

The MySQL replica is requesting a binary log position that no longer exists on the primary. The binlog has been purged (manually or by expire_logs_days/binlog_expire_logs_seconds) before the replica consumed it. The replica cannot continue replication from its saved position and must be re-initialized.

generic

Workarounds

  1. 90% success Re-initialize the replica from a fresh backup of the primary
    Take a consistent snapshot: mysqldump --single-transaction --source-data=2 --all-databases > dump.sql (or use xtrabackup for faster backups). Restore on replica. Use the binlog position from the backup to set up replication: CHANGE REPLICATION SOURCE TO SOURCE_LOG_FILE='binlog.000123', SOURCE_LOG_POS=456; START REPLICA;
  2. 85% success Use GTID-based replication to automatically find the correct position
    If GTID is enabled (gtid_mode=ON), set up replication with: CHANGE REPLICATION SOURCE TO SOURCE_AUTO_POSITION=1; START REPLICA; GTID-based replication does not depend on binlog file positions. For future prevention, ensure binlog_expire_logs_seconds is greater than your maximum replication lag.

Dead Ends

Common approaches that don't work:

  1. Resetting the replica's binary log position with CHANGE MASTER TO without re-initializing data 85% fail

    Pointing the replica to a new binlog position without a fresh data snapshot creates data drift. The replica misses all changes between the old (purged) position and the new position, leading to silent data inconsistency that is extremely difficult to detect and fix.

  2. Disabling binlog purging entirely to prevent future occurrences 75% fail

    Without binlog purging, binary logs accumulate indefinitely and will fill the disk. This trades a replication error for a disk full outage, which is worse. Instead, configure a reasonable retention period and monitor replication lag.

Error Chain

Leads to:
Preceded by:
Frequently confused with: