[php-src] Issue #12513: DNS lookup failure in mysqli_real_connect()

From: Date: Tue, 24 Oct 2023 16:21:59 +0000
Subject: [php-src] Issue #12513: DNS lookup failure in mysqli_real_connect()
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-245640@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/12513 Author: nyaka111 ### Description We're getting an intermittent error when calling mysqli_real_connect function. This is the error: PHP Warning: mysqli_real_connect(): php_network_getaddresses: getaddrinfo for MYSQL_SEVER_HOSTNAME failed: Name or service not known in ... It happens every time the DNS record TTL expires. We're using AWS Aurora and the DNS record TTL's every 5 seconds. Running mysqli_real_connect in a cycle would fail every 5 seconds. To rule out the other possibilities we created a DNS name with a TTL of 60 seconds and it failed every 60 seconds. This is the code we were able to consistently replicate the issue with: ``` for ($i = 0; $i < 100; $i++) { test_mysqli_connect($i); usleep(250000); } function test_mysqli_connect() { global $CONF; $dbh = mysqli_init(); mysqli_real_connect($dbh, $CONF["DB"]["db_host"], $CONF["DB"]["db_user"], $CONF["DB"]["db_pass"], $CONF["DB"]["db_name"], 3306, NULL, MYSQLI_CLIENT_SSL|MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT); } ``` We also tried running gethostbyname and dns_get_record in the same cycle, and they never seem to fail. Setup: PHP Version => 8.2.7 System => Linux XX.XX.XX.XX 6.1.0-13-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.55-1 (2023-09-29) x86_64 PHP API => 20220829 PHP Extension => 20220829 Zend Extension => 420220829 Zend Extension Build => API420220829,NTS PHP Extension Build => API20220829,NTS MySQL server: 5.7.40-log MySQL Community Server (GPL) Debian packages: default-libmysqlclient-dev/stable,now 1.1.0 amd64 [installed] default-mysql-client/stable,now 1.1.0 all [installed] mysql-common/stable,now 5.8+1.1.0 all [installed] libapache2-mod-php8.2/stable,stable-security,now 8.2.7-1~deb12u1 amd64 [installed,automatic] php-bz2/stable,now 2:8.2+93 all [installed] php-cli/stable,now 2:8.2+93 all [installed] php-common/stable,now 2:93 all [installed] php-curl/stable,now 2:8.2+93 all [installed] php-dev/stable,now 2:8.2+93 all [installed] php-gd/stable,now 2:8.2+93 all [installed] php-imap/stable,now 2:8.2+93 all [installed] php-json/stable,now 2:8.2+93 all [installed] php-mcrypt/stable,now 3:1.0.5-4 amd64 [installed] php-memcache/stable,now 8.0+4.0.5.2+3.0.9~20170802.e702b5f9+-8 amd64 [installed] php-mysql/stable,now 2:8.2+93 all [installed] php-pear/stable,now 1:1.10.13+submodules+notgz+2022032202-2 all [installed] php-readline/stable,now 2:8.2+93 all [installed] php-snmp/stable,now 2:8.2+93 all [installed] php-xml/stable,now 2:8.2+93 all [installed] php-xmlrpc/stable,now 3:1.0.0~rc3-6 amd64 [installed] php8.2-bz2/stable,stable-security,now 8.2.7-1~deb12u1 amd64 [installed,automatic] php8.2-cli/stable,stable-security,now 8.2.7-1~deb12u1 amd64 [installed,automatic] php8.2-common/stable,stable-security,now 8.2.7-1~deb12u1 amd64 [installed,automatic] php8.2-curl/stable,stable-security,now 8.2.7-1~deb12u1 amd64 [installed,automatic] php8.2-dev/stable,stable-security,now 8.2.7-1~deb12u1 amd64 [installed] php8.2-gd/stable,stable-security,now 8.2.7-1~deb12u1 amd64 [installed,automatic] php8.2-imap/stable,stable-security,now 8.2.7-1~deb12u1 amd64 [installed,automatic] php8.2-mcrypt/stable,now 3:1.0.5-4 amd64 [installed,automatic] php8.2-memcache/stable,now 8.0+4.0.5.2+3.0.9~20170802.e702b5f9+-8 amd64 [installed,automatic] php8.2-mysql/stable,stable-security,now 8.2.7-1~deb12u1 amd64 [installed,automatic] php8.2-opcache/stable,stable-security,now 8.2.7-1~deb12u1 amd64 [installed,automatic] php8.2-readline/stable,stable-security,now 8.2.7-1~deb12u1 amd64 [installed,automatic] php8.2-snmp/stable,stable-security,now 8.2.7-1~deb12u1 amd64 [installed,automatic] php8.2-xml/stable,stable-security,now 8.2.7-1~deb12u1 amd64 [installed,automatic] php8.2-xmlrpc/stable,now 3:1.0.0~rc3-6 amd64 [installed,automatic] php8.2/stable,stable-security,now 8.2.7-1~deb12u1 all [installed,automatic] php/stable,now 2:8.2+93 all [installed] pkg-php-tools/stable,now 1.44 all [installed,automatic] Also, we ran the same script on our “old” system (PHP 7.0.33-0+deb9u12, Debian 4.9.189-3+deb9u2 (2019-11-11) x86_64) which connects to the same MySQL server, and it worked without failing. ### PHP Version PHP 8.2.7 ### Operating System Debian 6.1.55-1 (2023-09-29) x86_64

« previous php.bugs (#245640) next »