#31782 [NEW]: Database selection fails intermittently with pconnect

From: Date: Mon, 31 Jan 2005 17:23:03 +0000
Subject: #31782 [NEW]: Database selection fails intermittently with pconnect
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-73129@lists.php.net to get a copy of this message
From: brian dot sanders at cometsystems dot com Operating system: Fedora Core 3 PHP version: 5.0.2 PHP Bug Type: MySQL related Bug description: Database selection fails intermittently with pconnect Description: ------------ I am having the following issue with pconnect on my development box: environment: I have an entry in my /etc/hosts file to point the hostname of a remote MySQL server to localhost. This allows me to test the production setup, while running both the application and database on my local machine. testing: I can connect as the application user via the mysql client to the local database by either 'localhost' or by the remote name (which is looped back to 'localhost.localdomain', as described above.) I can select the database 'use my_db' repeatedly without failure. symtoms: My PHP app uses mysql_pconnect() to connect to the remote database server (again, which is looped back to 'localhost.localdomain'.) Intermittenly, PHP connects to the server, but fails to select the database. Unlike bug #24977, mysql_select_db() does return false (as it should.) This issue seems to be tied to the persistant connections. mysql_select_db() might fail 5-20 times, then work 5-20 times, then fail again. Strangely enough, the app never fails to connect, but only to select the database. If I change mysql_pconnect() to mysql_connect(), the problem disappears. Also, if I change the app's configuration to connect to localhost.localdomain (instead of the looped-back remote address) the problem disappears. So to sum up, using mysql_pconnect() to connect to a non-localhost hostname on the local machine causes mysql_select_db to fail intermittenly. Here's the info on my box: OS: Fedora Core 3 kernel: 2.6.10-1.741_FC3smp MySQL server: 3.23.58 MySQL client: Ver 11.18 Distrib 3.23.58, for redhat-linux-gnu (i386) Apache: 1.3.33 built from source PHP: 5.0.2 built from source Reproduce code: --------------- /etc/hosts: 127.0.0.1 localhost.localdomain localhost 127.0.0.1 some.faroffserver.com PHP app: $db = mysql_pconnect('some.faroffserver.com', 'user', ''); if(!$db) { die('Could not connect to database'); } else { if(!mysql_select_db('my_db', $db)) { die('Could not select database.'); } } Expected result: ---------------- Nothing (mysql_select_db() returns true) Actual result: -------------- Sometimes mysql_select_db() returns false. -- Edit bug report at http://bugs.php.net/?id=31782&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31782&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31782&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31782&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=31782&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=31782&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=31782&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=31782&r=needscript Try newer version: http://bugs.php.net/fix.php?id=31782&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=31782&r=support Expected behavior: http://bugs.php.net/fix.php?id=31782&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=31782&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=31782&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=31782&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31782&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=31782&r=dst IIS Stability: http://bugs.php.net/fix.php?id=31782&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=31782&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=31782&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=31782&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=31782&r=mysqlcfg

« previous php.bugs (#73129) next »