ID:               31782
 User updated by:  brian dot sanders at cometsystems dot com
 Reported By:      brian dot sanders at cometsystems dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         MySQL related
 Operating System: Fedora Core 3
 PHP Version:      5.0.2
 New Comment:

I have not been able to reproduce this since me last update to PHP, so
I am closing it for now...


Previous Comments:
------------------------------------------------------------------------

[2005-01-31 18:23:02] brian dot sanders at cometsystems dot com

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 this bug report at http://bugs.php.net/?id=31782&edit=1

Reply via email to