MySQL fatal error 1236

MySQL error message when attempting to start a replication slave:

Got fatal error 1236: ‘Could not find first log file name in binary log index file’ from master when reading data from binary log

I banged my head against a wall for a short period of time trying resolve this one. The resolution is easy, but I didn’t find it in my searching. Hopefully this will allow someone to move forward more quickly than I did, providing I am not the only one that didn’t immediately realize what was going on. The full error reads something like:

060903 11:01:58 [Note] Slave SQL thread initialized, starting replication in log '/var/mysql/logs/mysql-log.000125' at position 97277001, relay log './slave-relay-bin.000001' position: 4
060903 11:01:58 [Note] Slave I/O thread: connected to master 'slave@master:3306', replication started in log '/var/mysql/logs/mysql-log.000125' at position 97277001
060903 11:01:58 [ERROR] Error reading packet from server: Could not find first log file name in binary log index file ( server_errno=1236)
060903 11:01:58 [ERROR] Got fatal error 1236: 'Could not find first log file name in binary log index file' from master when reading data from binary log
060903 11:01:58 [Note] Slave I/O thread exiting, read up to log '/var/mysql/logs/mysql-log.000125', position 97277001

The slave was being started from an InnoDB Hot Backup created on the master. After restoring the backup and starting up MySQL, the following binlog position was reported:

InnoDB: Last MySQL binlog file position 0 97277001, file name /var/mysql/logs/mysql-log.000125

which suggests the change master statement:

CHANGE MASTER TO
MASTER_HOST='master',
MASTER_USER='slave',
MASTER_LOG_FILE='/var/mysql/logs/mysql-log.000125',
MASTER_LOG_POS=97277001;

However, the full path to the log file is what causes the ‘Could not find first log file name in binary log index file’ error. MySQL looks for the log file in the defined log directory, /var/mysql/logs in this case. Simply adjusting the change master statement:

CHANGE MASTER TO
MASTER_HOST='master',
MASTER_USER='slave',
MASTER_LOG_FILE='mysql-log.000125',
MASTER_LOG_POS=97277001;

results in:

060903 11:15:16 [Note] Slave SQL thread initialized, starting replication in log 'mysql-log.000125' at position 97277001, relay log './slave-relay-bin.000001' position: 4
060903 11:15:16 [Note] Slave I/O thread: connected to master 'slave@master:3306', replication started in log 'mysql-log.000125' at position 97277001

And we’re replicating. Maybe if I had more occasion to bring up new MySQL replication slaves, this would have been obvious.

This entry was posted in Technology. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

22 Comments

  1. Ingo
    Posted November 30, 2006 at 11:01 pm | Permalink

    Thanks! Was struggling with the same problem, you saved me lots of time.

  2. Thorsten
    Posted January 20, 2007 at 6:43 am | Permalink

    Hi Doug,
    thanks a million! Setting up mysql replication I accidentally mistyped the logfile name (change master to master_log_file=’mysql-bin-xxx’ instead of ‘… mysql-bin.xxx’) which leads to the same error. Stupid mistake and I overlooked it many times. After having read this website I immediately knew what was wrong. Thanks again!

  3. Burkhart
    Posted January 26, 2007 at 4:53 am | Permalink

    Hey Doug,

    thanx, that was the hint into the right direction. In my setup I found two very similar but non the less other causes (and solutions of course):

    Due to a problem on the master (still to be investigated) one bin-log wasn’t closed correctly and depending on the replication progress of different slaves the problem was different:

    slave #1
    ========
    … was pointing to log-bin.000032 pos: 422281850. I read the log using the command

    shell: mysqlbinlog log-bin.000032 | less

    searched for the given position using the command:

    /422281850

    and found the end of the file. So I pointed the slave to the beginning of the next log-bin

    stop slave;
    CHANGE MASTER TO MASTER_LOG_FILE=’log-bin.000033′, MASTER_LOG_POS=4;
    start slave;

    replication worked fine again on this machine.

    slave #2
    ========
    … was pointing to log-bin.000032 pos: 399012105.

    I think that this slave didn’t finish replication when the problem came up, so the first solution would not fit this slave (unless we could confirm only reading commands in those last few K of queries)

    Thinking about the text message: “Could not find first log file name in binary log index file? from master when reading data from binary log”, I opened master.info on the master and found a list of all existing log-bins, but not the log-bin.000032 I found i. Assuming that mysql wasn’t able to update the master.info I added the missing log-bin.000032 and restarted the slave.

    replication started again and is now running ok for a few hours.

    I did a small script to compare the row numbers of all tables on all servers and found it working so far.

    Conclusion
    ==========
    Those two ways of repair might not be the highly official ones, but brought me back on track.

    Hope this helps anybody like this thread helped me a lot.

    thanx Doug

    cheers
    Burkhart

  4. doug
    Posted January 26, 2007 at 9:07 am | Permalink

    Thanks, Burkhart. Indeed not an official solution, I’m sure, but if the alternative is rebuilding the slave from a backup or fresh master dump (which is not recommended if the master db is using InnoDB as the engine and you cannot stop updates), an unofficial solution that works can save both time and money.

  5. Posted September 5, 2007 at 6:11 am | Permalink

    We found out that this error came from LOAD DATA INFILE command in MySQL 5.0.41 and only on Windows2003 Server. That is where we encountered it first time!

  6. Posted September 5, 2007 at 6:12 am | Permalink

    But still dont know whats wrong. Using same queries on Server 2000 and XP it worked ok.

  7. Sean K.
    Posted September 6, 2007 at 2:32 pm | Permalink

    Similar issue.

    I had a space inside the quotes after the file name like this:

    MASTER_LOG_FILE=’mysql-bin.000031 ‘

    Your post got me thinking about the good ole UE. Thanks.

  8. Posted September 7, 2007 at 10:28 am | Permalink

    Hello, I had the same problem. But I did two things to avoid this kind of problem…

    I changed the path for the bin log file xxxx.000001 inside the data folder and one more
    important thing you should check the read buffer size in mysql variables. make it 256K.
    If its in M make it really less about 192-256K. read-buffer-size. In my.ini… I think you will get rid of 1236 errors.. We encountered this errors when using LOAD DATA INFILE…
    On MySQL 5.0.27, 5.0.41 and 5.0.45.

    C ya and Good luck!

  9. Posted February 14, 2008 at 2:44 am | Permalink

    Thank you and all of who leave comment.

    I have same problems as Burkhart (January 26, 2007)

    You saved me lots of time ;)

  10. Halfasleep
    Posted May 20, 2009 at 12:37 am | Permalink

    I had this problem after replication got messed up, so I tried to start again with it (the system wasn’t live yet). It wouldn’t start whatever I did, until I did a ‘LOAD DATA FROM MASTER’ on all the slaves. Hope this helps somone

  11. doug
    Posted May 20, 2009 at 8:55 am | Permalink

    @Halfasleep: Thanks for the tip. What version of MySQL are you using? Maybe that makes a difference.

  12. Dhananjay
    Posted May 28, 2009 at 11:28 pm | Permalink

    Hi,i too faced similar problem.In my case the replication was broken because of ‘max_allowed_packet’.A big query was logged in the binary log and the same was not able to communicate with slave.By default the packet size will be 1MB.I have increased the ‘max_allowed_packet’ to 16M on both master and slave.
    Steps: stop slave,change master,start slave.

    Note:When you’re using CHANGE MASTER TO to set start position for the slave you’re specifying position for SQL thread and so you should use Relay_Master_Log_File:Exec_Master_Log_Pos. Otherwise you’re going to ruin your replication.

  13. doug
    Posted May 28, 2009 at 11:38 pm | Permalink

    @Dhananjay: I have seen this happen as well. Thanks for the info.

  14. Anon
    Posted September 28, 2009 at 10:18 am | Permalink

    A HUGE thank you to Burkhart and Doug!!!

    Came in today and there was: Could not find first log file name in binary log index file ( server_errno=1236)

    It popped up after a master reboot over the weekend. Checked the log file and it was indeed at the end. Set replication to the next file at first position (which was also 4 )and everything came right back up.

    14 hours or so saved by not re-replicating from scratch.

  15. Patricia
    Posted November 4, 2009 at 10:14 am | Permalink

    This page helped (and especially the comments).

    My error was:
    ERROR] Got fatal error 1236: ‘Client requested master to start replication from impossible position’ from master when reading data from binary log

    My fix on the slave was to be:
    LOAD DATA FROM MASTER;

    However I first had to grant extra privileges to my account from the master:
    grant reload, replication client on *.* to ‘repl-user’@'server-name’

  16. Charlie Roche
    Posted May 2, 2011 at 8:58 am | Permalink

    Hi. I had this problem too and there’s another reason this error occurs. Case sensitivity of the table names. I found that it’s best to have these global settings the same on the master and slave. Try this on both to see if they are different.

    show variables where
    Variable_name = ‘lower_case_table_names’ OR
    Variable_name=’lower_case_file_system’;

    These should be the same on both master and slave.

  17. Charlie Roche
    Posted May 2, 2011 at 9:06 am | Permalink

    Update to the previous post. Here’s a link to the MySQL documentation that explains this – see the “Note” at the end of this page.

    How Servers Evaluate Replication Filtering Rules

  18. Leslie
    Posted May 25, 2011 at 8:44 am | Permalink

    Awesome post, and comments. Definitely saved me a ton of time (when I had *none* to spare). Thanks to all who contributed.

  19. Patrick Dorion
    Posted August 3, 2011 at 2:10 pm | Permalink

    This is great and I also lost a few moments off of my life with this one. It would, however, have saved me even more time if it was posted on the MySQL Community Server Community pages.

  20. Suresh
    Posted October 11, 2011 at 10:33 pm | Permalink

    Thanks a lot !! saved lot of time for me.

  21. Ingor
    Posted February 15, 2012 at 1:35 pm | Permalink

    Thanks for the info! Saved me lots of time!

  22. Dave
    Posted July 29, 2012 at 12:52 pm | Permalink

    Although my problem was a bad filename and not a path issue, your post pointed me in the right direction. Thanks.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>