Re: PHP/Apache not totally closing MySQL connections

From: Date: Sun, 18 Nov 2001 04:10:15 +0000
Subject: Re: PHP/Apache not totally closing MySQL connections
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-14418@lists.php.net to get a copy of this message
At 18.11.2001 02:06, Bob Maple wrote:
I've been through the bug database a couple of times, and scanned through the list archives before joining, but haven't exactly found anything that matches what is happening in my case. First, dirty details: I am running MySQL 3.23.33, Apache 1.3.19, and PHP 4.0.6 under an RH system on kernel 2.2.19. PHP running as a module in Apache.
Good, pretty complete details.
I am having a little quirk with persistant connections with MySQL. The connections themselves work; However, after a while when the connections time out, they don't seem to be closing all the way. For instance, right now if I do a netstat, among some other connections I get: Proto Recv-Q Send-Q Local Address
tcp        1      0 burner.com:4848         burner.com:mysql        CLOSE
[munge-alert!] This is strange as the normal output from netstat should look like this
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 localhost:46764         localhost:imap4s        ESTABLISHED
tcp        0      0 localhost:imap4s        localhost:46764         ESTABLISHED
Yours seem to miss out at least to headings, who knows what else is missing? and there is no such state as "CLOSE", so I'll assume for the rest of the email that you're refering to CLOSED.
This has been there and been in "CLOSE" state all day. It was there yesterday. It will be there tomorrow. MySQL has terminated the connection as far as it cares (if I "mysqladmin processlist", no connections show up.) Indeed, if I shut down the MySQL server, the socket remains. Only if I shut down Apache will it ever go away. So, if left going for awhile, tons of these dead sockets will pile up.
nope, if you leave it going for awhile nothing out of the ordinary happens, the socket will be reused (when it's time is up). the reason it doesn't "go away" until Apache is closed is that this is apache's socket, and not MySQL's, as the forreign address is the :mysql.
Before I post a bug report, anyone have any ideas?
Yes, read netstat(8). and I quote: CLOSED The socket is not being used. if the socket was dead you'd either see
       CLOSE_WAIT
              The remote end  has  shut  down,  waiting  for  the
              socket to close.
       LAST_ACK
              The  remote  end  has  shut down, and the socket is
              closed. Waiting for acknowledgement.
(or even a time_wait, but only for a limited time, unless you've got some nifty problems with loopback.) What is the problem here really? MySQL isn't chewing resources, Apache isn't chewing resources, the fact of the matter is that you're seeing closed sockets, sockets that will be reused when apache+php reconnects to MySQL. The only intriguing part about your post is that the Recv-Q is still 1, but all in all I wouldn't worry... -- Andreas D Landmark / noXtension Real Time, adj.: Here and now, as opposed to fake time, which only occurs there and then.

« previous php.db (#14418) next »