MySQL replica error 'Could not find first log file name in binary log index file' after scripted binlog rotation during backup
Environment
Primary MySQL 8.0.32 on CentOS 7, replica MySQL 8.0.32 on CentOS 7. Primary runs custom backup script that rotates binary logs via mysqladmin flush-logs and moves old binlogs off to backup storage; replication uses GTID-based replication with replication user having REPLICATION SLAVE privileges.
Symptoms
Replica IO thread stops with error: 'Could not find first log file name in binary log index file' and SQL thread lags. Replica reports 'Got fatal error 1236 from master during replication'. The replica's relay logs grow but no new events apply.
Observations
On primary, binlog index (.index) contains references to moved files but rotated file names differ from replica's expected; backup script moved binlog files without updating master.info or without using mysqladmin flush-logs + purge. The replica's SHOW SLAVE STATUS shows Master_Log_File referencing a file that no longer exists on primary and MASTER_POS_WAIT returns immediately with error.
Already attempted
Tried START SLAVE, CHANGE MASTER TO MASTER_LOG_FILE='...' MASTER_LOG_POS=..., but primary's current binlog set doesn't include the requested file. Restoring moved binlog files to primary's binlog dir briefly allowed replica to resume but subsequent replication jumped to a different GTID sequence and stalled again.
Question
How to safely reconcile the replica without data loss when primary's old binlog files were moved by the backup script? What steps to recover replication and prevent recurrence?
Verified community troubleshooting
No answers yet..
Incident analysis
Most likely causes
Summary
Suggested Fixes
Continue troubleshooting
Related troubles
Matched from the title, description and tags
- Databases27% match
MySQL Replica Reports Binlog Checksum Mismatch After Changing Binlog_Format to ROW on Primary
Open0 answers - Databases27% match
Percona XtraBackup streaming aborts with 'stream ended' during backup of large InnoDB tables while binlog rotation runs
Open0 answers - Databases22% match
MySQL replica SQL thread idles and relay logs grow after short network blips — slave lags and no obvious errors
Open0 answers - Databases21% match
MySQL replica SQL thread stalls with 'Waiting for table metadata lock' after direct ALTER TABLE on primary during peak writes
Open0 answers - Databases20% match
MySQL replica stops with GTID mismatch after skipping a transaction during a network outage
Open0 answers