Bug #2143 slave relay-log name error
Submitted: 17 Dec 2003 11:59 Modified: 17 Dec 2003 14:22
Reporter: Dathan Pattishall Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:4.0.16 OS:Linux (RedHat 7.3 (all OS))
Assigned to: Guilhem Bichot CPU Architecture:Any

[17 Dec 2003 11:59] Dathan Pattishall
Description:

If you set in my.cnf
relay-log       = /db/loga/mysql/dbslave-relay-bin
relay-log-index     = /var/lib/mysql/dbslave-relay-bin.index
relay-log-info-file = /var/lib/mysql/relay-log.info

Then all relay bin logs should be dbslave-relay-bin.0XX, but if you reset a slave a 0 byte file gets created with the default relay-bin name i.e. `hostname`-relay-bin.0XX

This claims INODES and fills up a filesystem if for instance a automatic recovery script of damaged relay bin logs is in place, using the technique as described below.

How to repeat:
SLAVE STOP; // not needed if slave has stopped on its own
RESET SLAVE;
SLAVE START; // steps not ness
SLAVE STOP; // steps not ness 
CHANGE MASTER TO <BLAH>
SLAVE START;

Suggested fix:
what ever var stores 

relay-log       = /db/loga/mysql/dbslave-relay-bin
master-info-file    = /var/lib/mysql/master.info
relay-log-index     = /var/lib/mysql/dbslave-relay-bin.index
relay-log-info-file = /var/lib/mysql/relay-log.info

ensure that on reset slave / slave start  mysql respects the name.
[17 Dec 2003 14:22] Guilhem Bichot
Hi,

I used Linux:
[guilhem@gbichot2 guilhem]$ uname -a
Linux gbichot2 2.4.21-0.13mdk #1 Fri Mar 14 15:08:06 EST 2003 i686 unknown unknown GNU/Linux

I used MySQL compiled from our source development tree, which equals to MySQL 4.0.17 (released in a few days).
Master server started like this:
[guilhem@gbichot2 guilhem]$ /home/mysql_src/mysql-4.0/sql/mysqld --defaults-file=/home/mysql_src/my_master.cnf --user=guilhem --datadir=/m/data/4/1 --server-id=1 --log-bin --language=/home/mysql_src/mysql-4.0/sql/share/english/ --skip-grant-tables

I have
[guilhem@gbichot2 db]$ ll /var/lib/mysql
total 0
[guilhem@gbichot2 db]$ ll /db/loga/mysql/
total 0

Then slave server started like this:
[guilhem@gbichot2 guilhem]$ /home/mysql_src/mysql-4.0/sql/mysqld  --defaults-file=/home/mysql_src/my_slave.cnf --skip-slave-start --user=guilhem --datadir=/var/lib/mysql --port=3307 --server-id=2 --socket=/tmp/mysql.sock.2 --language=/home/mysql_src/mysql-4.0/sql/share/english/ --master_host=127.0.0.1 --master_port=3306 --master_user=root --master_password=  --skip-grant-tables --relay-log=/db/loga/mysql/dbslave-relay-bin --relay-log-index=/var/lib/mysql/dbslave-relay-bin.index --relay-log-info-file=/var/lib/mysql/relay-log.info --master-info-file=/var/lib/mysql/master.info --skip-innodb
/home/mysql_src/mysql-4.0/sql/mysqld: ready for connections.
Version: '4.0.17-debug'  socket: '/tmp/mysql.sock.2'  port: 3307

[guilhem@gbichot2 db]$ ll /db/loga/mysql/
total 4
-rw-rw----    1 guilhem  qq              4 Dec 17 23:11 dbslave-relay-bin.001
[guilhem@gbichot2 db]$ ll /var/lib/mysql
total 16
-rw-rw----    1 guilhem  qq             37 Dec 17 23:11 dbslave-relay-bin.index
-rw-rw----    1 guilhem  qq              6 Dec 17 23:11 gbichot2.pid
-rw-rw----    1 guilhem  qq             26 Dec 17 23:11 master.info
-rw-rw----    1 guilhem  qq             42 Dec 17 23:11 relay-log.info

[guilhem@gbichot2 db]$ mysql2
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.0.17-debug

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

SLAVE> start slave;
Query OK, 0 rows affected (0.01 sec)

SLAVE> show slave status\G
*************************** 1. row ***************************
          Master_Host: 127.0.0.1
          Master_User: root
          Master_Port: 3306
        Connect_retry: 3
      Master_Log_File: gbichot2-bin.001
  Read_Master_Log_Pos: 79
       Relay_Log_File: dbslave-relay-bin.001
        Relay_Log_Pos: 122
Relay_Master_Log_File: gbichot2-bin.001
     Slave_IO_Running: Yes
    Slave_SQL_Running: Yes
      Replicate_do_db:
  Replicate_ignore_db:
           Last_errno: 0
           Last_error:
         Skip_counter: 0
  Exec_master_log_pos: 79
      Relay_log_space: 122
1 row in set (0.00 sec)

SLAVE> Bye

[guilhem@gbichot2 db]$ ll /var/lib/mysql /db/loga/mysql/
/db/loga/mysql/:
total 4
-rw-rw----    1 guilhem  qq            122 Dec 17 23:12 dbslave-relay-bin.001

/var/lib/mysql:
total 16
-rw-rw----    1 guilhem  qq             37 Dec 17 23:11 dbslave-relay-bin.index
-rw-rw----    1 guilhem  qq              6 Dec 17 23:11 gbichot2.pid
-rw-rw----    1 guilhem  qq             43 Dec 17 23:12 master.info
-rw-rw----    1 guilhem  qq             61 Dec 17 23:12 relay-log.info

[guilhem@gbichot2 db]$ mysql2
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 4.0.17-debug

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

SLAVE> stop slave;
Query OK, 0 rows affected (0.00 sec)

SLAVE> Bye
[guilhem@gbichot2 db]$ ll /var/lib/mysql /db/loga/mysql/
/db/loga/mysql/:
total 4
-rw-rw----    1 guilhem  qq            122 Dec 17 23:12 dbslave-relay-bin.001

/var/lib/mysql:
total 16
-rw-rw----    1 guilhem  qq             37 Dec 17 23:11 dbslave-relay-bin.index
-rw-rw----    1 guilhem  qq              6 Dec 17 23:11 gbichot2.pid
-rw-rw----    1 guilhem  qq             43 Dec 17 23:12 master.info
-rw-rw----    1 guilhem  qq             61 Dec 17 23:12 relay-log.info

[guilhem@gbichot2 db]$ mysql2
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5 to server version: 4.0.17-debug

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

SLAVE> reset slave;
Query OK, 0 rows affected (0.00 sec)

SLAVE> Bye
[guilhem@gbichot2 db]$ ll /var/lib/mysql /db/loga/mysql/
/db/loga/mysql/:
total 4
-rw-rw----    1 guilhem  qq              4 Dec 17 23:15 dbslave-relay-bin.001

/var/lib/mysql:
total 8
-rw-rw----    1 guilhem  qq             37 Dec 17 23:15 dbslave-relay-bin.index
-rw-rw----    1 guilhem  qq              6 Dec 17 23:11 gbichot2.pid

[guilhem@gbichot2 db]$ mysql2
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6 to server version: 4.0.17-debug

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

SLAVE> start slave;
Query OK, 0 rows affected (0.01 sec)

SLAVE> Bye
[guilhem@gbichot2 db]$ ll /var/lib/mysql /db/loga/mysql/
/db/loga/mysql/:
total 4
-rw-rw----    1 guilhem  qq            122 Dec 17 23:16 dbslave-relay-bin.002

/var/lib/mysql:
total 16
-rw-rw----    1 guilhem  qq             37 Dec 17 23:16 dbslave-relay-bin.index
-rw-rw----    1 guilhem  qq              6 Dec 17 23:11 gbichot2.pid
-rw-rw----    1 guilhem  qq             43 Dec 17 23:16 master.info
-rw-rw----    1 guilhem  qq             61 Dec 17 23:16 relay-log.info

[guilhem@gbichot2 db]$ mysql2
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9 to server version: 4.0.17-debug

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

SLAVE> stop slave;
Query OK, 0 rows affected (0.00 sec)

SLAVE> Bye
[guilhem@gbichot2 db]$ ll /var/lib/mysql /db/loga/mysql/
/db/loga/mysql/:
total 4
-rw-rw----    1 guilhem  qq            122 Dec 17 23:16 dbslave-relay-bin.002

/var/lib/mysql:
total 16
-rw-rw----    1 guilhem  qq             37 Dec 17 23:16 dbslave-relay-bin.index
-rw-rw----    1 guilhem  qq              6 Dec 17 23:11 gbichot2.pid
-rw-rw----    1 guilhem  qq             43 Dec 17 23:16 master.info
-rw-rw----    1 guilhem  qq             61 Dec 17 23:16 relay-log.info

[guilhem@gbichot2 db]$ mysql2
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10 to server version: 4.0.17-debug

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

SLAVE> change master to master_host='127.0.0.1';
Query OK, 0 rows affected (0.00 sec)

SLAVE> Bye
[guilhem@gbichot2 db]$ ll /var/lib/mysql /db/loga/mysql/
/db/loga/mysql/:
total 4
-rw-rw----    1 guilhem  qq              4 Dec 17 23:16 dbslave-relay-bin.001

/var/lib/mysql:
total 16
-rw-rw----    1 guilhem  qq             37 Dec 17 23:16 dbslave-relay-bin.index
-rw-rw----    1 guilhem  qq              6 Dec 17 23:11 gbichot2.pid
-rw-rw----    1 guilhem  qq             43 Dec 17 23:16 master.info
-rw-rw----    1 guilhem  qq             61 Dec 17 23:16 relay-log.info

[guilhem@gbichot2 db]$ mysql2
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11 to server version: 4.0.17-debug

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

SLAVE> start slave;
Query OK, 0 rows affected (0.01 sec)

SLAVE> Bye
[guilhem@gbichot2 db]$ ll /var/lib/mysql /db/loga/mysql/
/db/loga/mysql/:
total 4
-rw-rw----    1 guilhem  qq            122 Dec 17 23:17 dbslave-relay-bin.001

/var/lib/mysql:
total 16
-rw-rw----    1 guilhem  qq             37 Dec 17 23:16 dbslave-relay-bin.index
-rw-rw----    1 guilhem  qq              6 Dec 17 23:11 gbichot2.pid
-rw-rw----    1 guilhem  qq             43 Dec 17 23:17 master.info
-rw-rw----    1 guilhem  qq             61 Dec 17 23:17 relay-log.info

[guilhem@gbichot2 db]$ mysql2
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14 to server version: 4.0.17-debug

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

SLAVE> flush logs;
Query OK, 0 rows affected (0.00 sec)

SLAVE> Bye
[guilhem@gbichot2 db]$ ll /var/lib/mysql /db/loga/mysql/
/db/loga/mysql/:
total 4
-rw-rw----    1 guilhem  qq              4 Dec 17 23:20 dbslave-relay-bin.002

/var/lib/mysql:
total 16
-rw-rw----    1 guilhem  qq             37 Dec 17 23:20 dbslave-relay-bin.index
-rw-rw----    1 guilhem  qq              6 Dec 17 23:11 gbichot2.pid
-rw-rw----    1 guilhem  qq             43 Dec 17 23:17 master.info
-rw-rw----    1 guilhem  qq             61 Dec 17 23:20 relay-log.info

So, I never get the `hostname`-relay-bin.* files. Names and directories for replication files (relay logs, relay log index file, info files) are honoured.

Regards,
Guilhem