Bug #15465 Unknown mysql host when used with a CNAME dns record
Submitted: 3 Dec 2005 22:19 Modified: 21 Jan 2006 9:25
Reporter: Sven Kamphuis Email Updates:
Status: No Feedback Impact on me:
None 
Category:Connectors: DBD::mysql ( Perl ) Severity:S2 (Serious)
Version:5.0.16 OS:Linux (linux)
Assigned to: CPU Architecture:Any

[3 Dec 2005 22:19] Sven Kamphuis
Description:
When upgrading from the mysql 3.22 client libraries and upgrading the perl DBI / DBD::mysql modules, we found that we could no longer connect to our database.
(Unknown mysql host: database.cb3rob.net).

I can't tell wether the bug lies in the perl modules or in the mysqlclient library itself.

We then figured out that it worked when we entered an ip address instead of a hostname, and then looked at the dns.

Turns out it only looks for A records instead of doing a normal gethostbyname().
so it does not find hosts with CNAME host records.

It also completely ignores /etc/nsswitch.conf and /etc/hosts.

Please fix this to use the normal DNS lookup scheme. (like mysql 3 did).

How to repeat:
set up a database host on ipv4, and give it a CNAME record to it's hostname
(say it's called scott.cb3rob.net and you CNAME it to database.cb3rob.net).

then make a perl dbi client (with mysql 5 client libraries and the latest DBI) on another box connect to the database.cb3rob.net host, and it will give the "Unknown mysql host" error.

also hosts that are in /etc/hosts but not in dns do not work.

Suggested fix:
make it use the normal gethostbyname() routine.
[3 Dec 2005 22:38] Sven Kamphuis
hmm the dns doesn't appear to be the problem..
problem occured -again- after changing to a records.
[3 Dec 2005 23:01] Sven Kamphuis
strace shows a whole lot of unusual stuff, and eventually it tries to open /tmp/.nscd_socket

when nscd is started, it suddenly works..
this is ofcourse no solution as we don't want to run nscd...
we just want it to properly resolve hostnames by itself.
[4 Dec 2005 13:41] Valeriy Kravchuk
Thank you for a problem report. Can you, please, try to connect to the same MySQL server using mysql client, or, even better, telnet <server> <your_port or 3306>. Inform about the results. 

(You should get some "trash" with MySQL server version in it if connection can be established. Like:

7
5.0.15-nt...)

If telnet can not connect to your MySQL server's port successfully, then either server not started, you used incorrect port number, or your machine's name resolution is broken.
[20 Dec 2005 23:02] Sven Kamphuis
ofcourse the database engine is running, it also works with all the other tools (mysql, telnet, etc.) the problem is just the resolving of the hostname from DBI.
changing the CNAME to an A record solved the problem for one try, but didn't work on most other tries.

whatever is in /etc/hosts, etc is not relevant, it doesn't work when we put the dbe host in that either, so it's not strictly dns itself.

it works when we specify the host as it's ipv4 ip address.

boxes use slackware libraries from slack 10.x (dunno which one exactly anymore), and the normal gethostbyname() routine works from all other programs perfectly. (also for the database host).
[20 Dec 2005 23:03] Sven Kamphuis
This problem does occur with all slackware boxes from that version when we update the libmysqlclient, perl, and dbi (in that order ofcourse).
[21 Dec 2005 9:25] Valeriy Kravchuk
Thank you for the additional checks. Please, specify the exact versions of libmysqlclient, perl and dbi. 

And, because IP-addresses works fine, please, send at least one of them. I wonder is there any of 206, 207, 232...235 numbers in it in dot notation.
[22 Jan 2006 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".