[debian-mysql] Bug#561999: mysql-server-5.0: "flush logs" corrupts mysql-bin.index

Andrew Pimlott andrew at pimlott.net
Mon Dec 21 21:45:12 UTC 2009


Package: mysql-server-5.0
Version: 5.0.51a-24+lenny2
Severity: normal

I have uncommented the log_bin setting in /etc/mysql/my.cnf in order to
to make my server a replication master.  This has been working fine, but
one day I executed "flush logs", and the slave started throwing errors:

    Dec 21 20:31:46 web3 mysqld.replica[23069]: 091221 20:31:46 [ERROR] Error reading packet from server: File '.000007' not found (Errcode: 2) ( server_errno=29)
    Dec 21 20:31:46 web3 mysqld.replica[23069]: 091221 20:31:46 [Note] Slave I/O thread: Failed reading log event, reconnecting to retry, log 'mysql-bin.000007' position 4
    Dec 21 20:31:46 web3 mysqld.replica[23069]: 091221 20:31:46 [Note] Slave: connected to master 'repl at db1:3306',replication resumed in log 'mysql-bin.000007' at position 4
    Dec 21 20:31:46 web3 mysqld.replica[23069]: 091221 20:31:46 [ERROR] Error reading packet from server: Could not find first log file name in binary log index file ( server_errno=1236)
    Dec 21 20:31:46 web3 mysqld.replica[23069]: 091221 20:31:46 [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
    Dec 21 20:31:46 web3 mysqld.replica[23069]: 091221 20:31:46 [Note] Slave I/O thread exiting, read up to log 'mysql-bin.000007', position 4

Wondering what had happened, I looked at my log directory:

    % cd /var/log/mysql
    % ls -l
    -rw-rw---- 1 mysql adm   13813 2009-12-19 18:32 mysql-bin.000001
    -rw-rw---- 1 mysql adm     117 2009-12-19 18:41 mysql-bin.000002
    -rw-rw---- 1 mysql adm     117 2009-12-19 18:43 mysql-bin.000003
    -rw-rw---- 1 mysql adm 1833587 2009-12-20 07:39 mysql-bin.000004
    -rw-rw---- 1 mysql adm 4698347 2009-12-21 07:53 mysql-bin.000005
    -rw-rw---- 1 mysql adm 8683203 2009-12-21 20:32 mysql-bin.000006
    -rw-rw---- 1 mysql adm      98 2009-12-21 20:32 mysql-bin.000007
    -rw-rw---- 1 mysql adm     224 2009-12-21 20:32 mysql-bin.index

That looks all right... but

    % cat mysql-bin.index
    /var/log/mysql/mysql-bin.000001
    /var/log/mysql/mysql-bin.000002
    /var/log/mysql/mysql-bin.000003
    /var/log/mysql/mysql-bin.000004
    /var/log/mysql/mysql-bin.000005
    /var/log/var/log/mysql/mysql-bin.000007

This really looks bad.  First, mysql-bin.000006 has disappeared, and
second, the path to mysql-bin.000007 is wrong.

I have not been able to reproduce this problem, but since it is fairly
serious I thought I should report it.

I think I managed to recover from this without stopping the database.  I
edited the mysql-bin.index file to fix it, then I issued another "flush
logs".  Now, mysql-bin.index has files 1-8 as expected, and I can resume
the replication successfully.

Andrew

#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
# 
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
[client]
port		= 3306
socket		= /var/run/mysqld/mysqld.sock

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket		= /var/run/mysqld/mysqld.sock
nice		= 0

[mysqld]
#
# * Basic Settings
#
user		= mysql
pid-file	= /var/run/mysqld/mysqld.pid
socket		= /var/run/mysqld/mysqld.sock
port		= 3306
basedir		= /usr
datadir		= /var/lib/mysql
tmpdir		= /tmp
language	= /usr/share/mysql/english
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address		= 127.0.0.1
#
# * Fine Tuning
#
key_buffer		= 16M
max_allowed_packet	= 16M
thread_stack		= 128K
thread_cache_size	= 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover		= BACKUP
#max_connections        = 100
#table_cache            = 64
#thread_concurrency     = 10
#
# * Query Cache Configuration
#
query_cache_limit       = 1M
query_cache_size        = 16M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
#log		= /var/log/mysql/mysql.log
#
# Error logging goes to syslog. This is a Debian improvement :)
#
# Here you can see queries with especially long duration
#log_slow_queries	= /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
#       other settings you may need to change.
server-id		= 1
log_bin			= /var/log/mysql/mysql-bin.log
sync_binlog		= 1
expire_logs_days	= 10
max_binlog_size         = 100M
#binlog_do_db		= include_database_name
#binlog_ignore_db	= include_database_name
#
# * BerkeleyDB
#
# Using BerkeleyDB is now discouraged as its support will cease in 5.1.12.
skip-bdb
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
# You might want to disable InnoDB to shrink the mysqld process by circa 100MB.
#skip-innodb
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem



[mysqldump]
quick
quote-names
max_allowed_packet	= 16M

[mysql]
#no-auto-rehash	# faster start of mysql but no tab completition

[isamchk]
key_buffer		= 16M

#
# * NDB Cluster
#
# See /usr/share/doc/mysql-server-*/README.Debian for more information.
#
# The following configuration is read by the NDB Data Nodes (ndbd processes)
# not from the NDB Management Nodes (ndb_mgmd processes).
#
# [MYSQL_CLUSTER]
# ndb-connectstring=127.0.0.1


#
# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/


-- System Information:
Debian Release: 5.0.3
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.31-302-rs (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages mysql-server-5.0 depends on:
ii  adduser                3.110             add and remove users and groups
ii  debconf [debconf-2.0]  1.5.24            Debian configuration management sy
ii  libc6                  2.7-18            GNU C Library: Shared libraries
ii  libdbi-perl            1.605-1           Perl5 database interface by Tim Bu
ii  libgcc1                1:4.3.2-1.1       GCC support library
ii  libmysqlclient15off    5.0.51a-24+lenny2 MySQL database client library
ii  libncurses5            5.7+20081213-1    shared libraries for terminal hand
ii  libreadline5           5.2-3.1           GNU readline and history libraries
ii  libstdc++6             4.3.2-1.1         The GNU Standard C++ Library v3
ii  libwrap0               7.6.q-16          Wietse Venema's TCP wrappers libra
ii  lsb-base               3.2-20            Linux Standard Base 3.2 init scrip
ii  mysql-client-5.0       5.0.51a-24+lenny2 MySQL database client binaries
ii  mysql-common           5.0.51a-24+lenny2 MySQL database common files
ii  passwd                 1:4.1.1-6         change and administer password and
ii  perl                   5.10.0-19lenny2   Larry Wall's Practical Extraction 
ii  psmisc                 22.6-1            Utilities that use the proc filesy
ii  zlib1g                 1:1.2.3.3.dfsg-12 compression library - runtime

Versions of packages mysql-server-5.0 recommends:
ii  heirloom-mailx [mailx 12.3+cvs20080629-1 feature-rich BSD mail(1)
pn  libhtml-template-perl <none>             (no description available)

Versions of packages mysql-server-5.0 suggests:
pn  tinyca                        <none>     (no description available)

-- debconf information:
  mysql-server-5.0/really_downgrade: false
  mysql-server-5.0/need_sarge_compat: false
  mysql-server-5.0/start_on_boot: true
  mysql-server/error_setting_password:
  mysql-server-5.0/nis_warning:
  mysql-server-5.0/postrm_remove_databases: false
  mysql-server/password_mismatch:
  mysql-server-5.0/need_sarge_compat_done: true





More information about the pkg-mysql-maint mailing list