error 99(?) : can't connect to MySQL server

2007-02-06 Thread Fagyal Csongor

Hi,

I have an interesting (a.k.a. frustrating) problem on MySQL 4.1.11.

I try to connect to the database via DBD::mysql. Everything works - except in a 
few cases (once in every 1 occasions, approximately) I get:

DBI connect('database=test:host=192.168.0.200','test',...) failed: Can't 
connect to MySQL server on '192.168.0.200' (99) at con.pl line 14

perror 99 gives me:
OS error code  99:  Cannot assign requested address

This doesn't make sense to me. I wrote a test script that looks like this:


for (1..5) {
$dbh = DBI-connect($dsn, $user, $password, {'RaiseError' = 1} );
my $sth = $dbh-prepare('SELECT * FROM users');
}


Periodically I get the above error.

I have tried to be more nice, after upgrading DBD and DBI, etc.:

for (1..5) {
 $dbh = DBI-connect($dsn, $user, $password, {'RaiseError' = 1} );
 my $sth = $dbh-prepare('SELECT * FROM users');
 $sth = undef;
 $dbh-disconnect;
 $dbh = undef;
}


But the same happens.


Then I straced the program. This is what I got:

restart_syscall(... resuming interrupted call ...) = 0
time(NULL)  = 1170758829
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 3
fcntl64(3, F_SETFL, O_RDONLY)   = 0
fcntl64(3, F_GETFL) = 0x2 (flags O_RDWR)
connect(3, {sa_family=AF_INET, sin_port=htons(3306), 
sin_addr=inet_addr(192.168.0.200)}, 16) = -1 EADDRNOTAVAIL (Cannot assign 
requested address)
shutdown(3, 2 /* send and receive */)   = -1 ENOTCONN (Transport endpoint is 
not connected)
close(3)= 0
write(1, Doesn\'t work. Reconnecting in 1 ..., 51) = 51
time(NULL)  = 1170758829
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigaction(SIGCHLD, NULL, {SIG_DFL}, 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
nanosleep({1, 0}, {1, 0})   = 0
time(NULL)  = 1170758830
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 3
fcntl64(3, F_SETFL, O_RDONLY)   = 0
fcntl64(3, F_GETFL) = 0x2 (flags O_RDWR)
connect(3, {sa_family=AF_INET, sin_port=htons(3306), 
sin_addr=inet_addr(192.168.0.200)}, 16) = -1 EADDRNOTAVAIL (Cannot assign 
requested address)
shutdown(3, 2 /* send and receive */)   = -1 ENOTCONN (Transport endpoint is 
not connected)



Anybody seen anything like this?


- Fagzal


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: error 99(?) : can't connect to MySQL server

2007-02-06 Thread Nils Meyer

Hi Faygal,

Fagyal Csongor wrote:

for (1..5) {
$dbh = DBI-connect($dsn, $user, $password, {'RaiseError' = 1} );
my $sth = $dbh-prepare('SELECT * FROM users');
}

I think you are simply running out of available outgoing ports with 
that. Here is some more insight on that topic:


http://www.mysqlperformanceblog.com/2006/11/12/are-php-persistent-connections-evil/

Don't be confused with the PHP mentioned, the first paragraphs apply to 
TCP/IP and mysql as whole.


regards
Nils

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: error 99(?) : can't connect to MySQL server

2007-02-06 Thread Fagyal Csongor

Nils Meyer wrote:


Hi Faygal,

Fagyal Csongor wrote:


for (1..5) {
$dbh = DBI-connect($dsn, $user, $password, {'RaiseError' = 1} );
my $sth = $dbh-prepare('SELECT * FROM users');
}

I think you are simply running out of available outgoing ports with 
that. Here is some more insight on that topic:


http://www.mysqlperformanceblog.com/2006/11/12/are-php-persistent-connections-evil/ 



Don't be confused with the PHP mentioned, the first paragraphs apply 
to TCP/IP and mysql as whole.


regards
Nils


Thanks, Nils.

Actually I got to the same conclusion, too... when this error appears, there are something 
like 15000 TCP connections around, mostly in TIME_WAIT. Too bad these 
connections linger around even after an explicit -disconnect().

I should be using a persistent connection anyway :)

- Csongor


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]