[mythtv-users] Re: mythweb2 having some more problems

Omer Shenker mail at omershenker.net
Thu Aug 7 23:36:24 EDT 2003


On Thu, 07 Aug 2003 14:25:22 -0700 Chris Germano wrote:
> Now I'm having some weird things happen. I just received a 
> MySQL too many 
> connections alert and now I can't access anything from 
> mythweb. Here is the 
> error:
> 
> --------------------------------------------------------------
> ------------------
> Warning at /var/www/html/mythweb2/includes/init.php, line 50:
> mysql_pconnect() [function.mysql-pconnect]: Too many connections
> --------------------------------------------------------------
> ------------------
> 
> --------------------------------------------------------------
> ------------------
> Fatal Error at /var/www/html/mythweb2/includes/init.php, line 51:
> Can't connect to the database server. Did you use the correct 
> settings in 
> config/conf.php?
> The system administrator has been notified and the problem 
> will be remedied 
> shortly.

Chris,

The quick fix is to edit /var/www/html/mythweb2/includes/init.php and change
mysql_pconnect() to mysql_connect(). The former function opens a persistent
connection, which means it's cached with that Apache child. The problem is
that you might have many more Apache children than you have available MySQL
connections. This is the server's max_connections parameter, which is 100 by
default. To set it higher, add the line "set-variable = max_connections=200"
(or whatever number) to /etc/my.cnf, creating that file if it doesn't exist.
BUT assuming your myth box isn't also doing other major tasks, you shouldn't
have to do that unless you're using a fantastic number of Apache children.
Try
$ mysqladmin [-u root -p] processlist
to see what open connections you have.

Attached is a very simple patch (-p1 from mythweb2/) to make persistent
connections optional and disabled by default. I argue that disabling them
should be the default, because users who don't understand the difference may
have a hard time debugging otherwise. Besides, for a typical myth box with
the MySQL server on a local socket, the overhead to open a new connection is
trivial compared to things like encoding video.

-- 
Omer Shenker                          http://omershenker.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: optional_mysql_persistence.patch
Type: application/octet-stream
Size: 1469 bytes
Desc: not available
Url : http://mythtv.org/pipermail/mythtv-users/attachments/20030807/d87b2f23/optional_mysql_persistence.obj


More information about the mythtv-users mailing list