[MDEV-21355] 10.4.11 cannot lookup "localhost" in DNS Created: 2019-12-18 Updated: 2020-01-12 Resolved: 2020-01-12 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Platform Windows, Server |
| Affects Version/s: | 10.4.11 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Drew W | Assignee: | Unassigned |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | Windows | ||
| Environment: |
Windows 2008 |
||
| Description |
|
Hi, I installed MariaDB 10.4.11 on a Windows server. Everything seems to work fine with my PHP apps but unfortunately I am unable to connect to the DB server via the 'mysql' command or from SQLYog. E:\MariaDB 10.4\bin>mysql -uuser -ppass ERROR 1042 (HY000): Can't get hostname for your address E:\MariaDB 10.4\bin>mysql -uuser -ppass Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 63 Server version: 10.4.11-MariaDB mariadb.org binary distribution I tried it about 20 times and 50% of the time it "Can't get hostname for my address" When I am able to connect in show processlist it looks like the hostname is: localhost I am able to connect consistently to the MySQL 5.5 instance that is installed on this machine from both the mysql command line tool as well as SQLYOG Here is what the server logs when it fails to look up the DNS (for some reason): Aborted connection 15 to db: 'unconnected' user: 'unauthenticated' host: 'connecting host' (This connection closed normally without authentication This seems like a bug because it should either always fail or always work. Why would it be able to "sometimes" lookup "localhost" and othertimes not be able to? |
| Comments |
| Comment by Vladislav Vaintroub [ 2019-12-19 ] |
|
Does anything change of you connect explicitly to host 127.0.0.1? |
| Comment by Drew W [ 2019-12-19 ] |
|
I'll try that but what does the client normally connect to when you just On Thu, Dec 19, 2019, 10:40 AM Vladislav Vaintroub (Jira) <jira@mariadb.org> |
| Comment by Vladislav Vaintroub [ 2019-12-20 ] |
|
According to the source code, it connects to "localhost". And it uses getaddrinfo() to enumerate out the IP addresses of the host. getaddrinfo() can return multiple addresses, and I believe there is no guarantee it always will be either IPv4 or IPv6 loopback address for "localhost", it probably depends on etc/hosts , and DNS server config. client will try to connect using address that getaddrinfo returns, in order in which it returns entries, until it succeeds. I do not think that there is any guarantee in which order getaddrinfo() returns its entries (since you asked about the order) And if client is using an IP address, which is not loopback, the server won't figure out loopback either. |
| Comment by Drew W [ 2019-12-20 ] |
|
E:\MariaDB 10.4\bin>mysql -h127.0.0.1 On Fri, Dec 20, 2019 at 2:05 AM Vladislav Vaintroub (Jira) <jira@mariadb.org> |
| Comment by Drew W [ 2019-12-20 ] |
|
Here is an example of it working and not working: E:\MariaDB 10.4\bin>mysql -h127.0.0.1 E:\MariaDB 10.4\bin>mysql -h127.0.0.1 E:\MariaDB 10.4\bin>mysql -h127.0.0.1 Keep in mind this is a Windows 2008 server and not Linux/Unix. I am trying to get this to work so that I can replicate this to a new |
| Comment by Vladislav Vaintroub [ 2019-12-20 ] |
|
Yes, I noticed Windows 2008, I'm aware it is EOLed in Jan 2020. According to the code I'm reading, this specific error is thrown, if either getpeername() or getnameinfo() would fail. My feeling is that getpeername() misbehaves, because setsockopt(SO_UPDATE_ACCEPT_CONTEXT) introduced in this commit https://github.com/MariaDB/server/commit/8f329e8d37e08c28d4e39d5c87ea22300285d9cd could have some subtle bug in Windows 2008, under some specific unknown circumstances . Now sure how that helps. Why connecting from PHP would do a better job, I've not even slightest idea. |
| Comment by Drew W [ 2019-12-20 ] |
|
I don't know if this helps or makes things more confusing but I noticed: It only fails the first time you try it after some amount of time.. see: E:\MariaDB 10.4\bin>mysql -h127.0.0.1 E:\MariaDB 10.4\bin>mysql -h127.0.0.1 E:\MariaDB 10.4\bin>mysql -h127.0.0.1 E:\MariaDB 10.4\bin>mysql -h127.0.0.1 E:\MariaDB 10.4\bin>mysql -h127.0.0.1 E:\MariaDB 10.4\bin>mysql -h127.0.0.1 - E:\MariaDB 10.4\bin>mysql -h127.0.0.1 E:\MariaDB 10.4\bin>mysql -h127.0.0.1 E:\MariaDB 10.4\bin>mysql -h127.0.0.1 E:\MariaDB 10.4\bin>mysql -h127.0.0.1 E:\MariaDB 10.4\bin>mysql -h127.0.0.1 E:\MariaDB 10.4\bin>mysql -h127.0.0.1 E:\MariaDB 10.4\bin>mysql -h127.0.0.1 E:\MariaDB 10.4\bin>mysql -h127.0.0.1 It seems like the remote application servers are able to connect to it consistently but I can't really trust it because it's acting really strange. Also the log on the server looks like this when it is failing: 2019-12-20 10:50:14 15 [Warning] Aborted connection 15 to db: 'unconnected' user: 'unauthenticated' host: 'connecting host' (This connection closed normally without authentication) Also MySQL 5.5 always works, I haven't tried 5.6 yet, 5.7 doesn't work on Windows 2008 so I can't try that. |
| Comment by Vladislav Vaintroub [ 2019-12-20 ] |
|
Interesting. "wait a little while", specifically. |
| Comment by Drew W [ 2019-12-20 ] |
|
Also noticed: when it works the server logs localhost but otherwise it logs connecting host for the hostname. 2019-12-20 11:01:35 12 [Warning] Aborted connection 12 to db: 'unconnected' user: 'Administrator' host: 'localhost' (This connection closed normally) I am wondering if maybe it just isn't waiting long enough for whatever thread in Windows needs to start up to provide the answer but then for subsequent tries the thing Windows needs to provide is already running. Sorry I sound like a fool I don't really know about the innerworkings of these things. |
| Comment by Vladislav Vaintroub [ 2019-12-20 ] |
|
Well, according to documentation, the code that is currently there should work fine, and not depend on any threads. Also, we did not have complaints about 10.4 so far, but I also presume Windows 2008 now would be exotic environment ,perhaps nobody was trying to run on it this far. I sort of hand-wave and blame Windows 2008 bugs for that, failing to see bugs in our code. |
| Comment by Drew W [ 2019-12-20 ] |
|
Well, it seems like: thread_handling=one-thread-per-connection does change the operation. 10:53 11:33 The only noticed downside is that it takes longer to kick back the authentication failure. I only installed 10.4 because I thought that it was officially supported, if not what version of Maria is supported on Windows 2008? thanks. |
| Comment by Drew W [ 2019-12-20 ] |
|
Are there any terrible consequences in running thread_handling=one-thread-per-connection ?? in production? |
| Comment by Vladislav Vaintroub [ 2019-12-20 ] |
|
I hope you do not run it for long time in production. Windows 2008 has 3 weeks more to live, both our and OS vendor's policy say that. thread_handling=one-thread-per-connection , all non-Windows has this default. MySQL has this default. |
| Comment by Drew W [ 2019-12-20 ] |
|
What I was asking is it safe to run it like that for a week or so while I On Fri, Dec 20, 2019, 3:35 PM Vladislav Vaintroub (Jira) <jira@mariadb.org> |
| Comment by Vladislav Vaintroub [ 2019-12-20 ] |
|
I'd guess thread_handling=one-thread-per-connection as a workaround will be fine. Most Linux installations just run that. Unless your workload consists of many thousands concurrent connections, this will work. |