Bug #37117 MASTER_HOST does not do DNS resolution
Submitted: 31 May 2008 10:31 Modified: 7 Jun 2008 9:50
Reporter: Thierry Coppey Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:5.0.51a (OpenBSD 4.3) OS:Other (OpenBSD 4.3)
Assigned to: CPU Architecture:Any
Tags: master host master_host dns resolution networking resolve name

[31 May 2008 10:31] Thierry Coppey
Description:
I have a procedure for attaching and replicating a server (becoming backup host of this server). Assume I already configured the connection, so only relevant commands are shown here.

If I setup the master with its ip, everything works nice
mysql> STOP SLAVE; CHANGE MASTER TO MASTER_HOST='192.168.0.1'; LOAD DATA FROM MASTER; START SLAVE;
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.13 sec)
Query OK, 0 rows affected (0.00 sec)

However if I setup the master with its hostname then it fails.
mysql> STOP SLAVE; CHANGE MASTER TO MASTER_HOST='bsd1.mydomain.com'; LOAD DATA FROM MASTER; START SLAVE;
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.01 sec)
ERROR 1218 (08S01): Error connecting to master: Unknown MySQL server host 'bsd1.mydomain.com' (-1)
Query OK, 0 rows affected (0.00 sec)

The system properly resolve bsd1.mydomain.com to 192.168.0.1 with /etc/hosts AND dns
Here is my.cnf relevant details (bsd1 is almost the same)

[client]
port = 30014
socket = /var/run/mysql/mysql.sock

[mysqld]
port = 30014
socket = /var/run/mysql/mysql.sock

log-bin=bsd2-bin
server-id = 1

How to repeat:
Try to slave any host with its hostname instead of IP.

Suggested fix:
Don't use names but IP, or solve it manually before issuing the SQL statement.
[7 Jun 2008 9:50] Susanne Ebrecht
Many thanks for writing a bug report.

Unfortunately I can't repeat this behaviour.

MySQL is using gethostbyname() function for resolve hostname/ip-address. Maybe this is a bug in your OpenBSD libc.