Mailing List Archive

mythweb2 having some more problems
Thanks for the help with the htaccess, I will have to figure out how to work
with it later as it is a great idea but if included there should be some
documentation in the readme.

I'm currently running the latest mythweb2 cvs and when I click Recorded
Programs I receive the following in the preview column.

"Warning at /var/www/html/mythweb2/includes/mythbackend.php, line 190:
copy(image_cache/1244_20030807120000_20030807130000.nuv.png)
[function.copy]: failed to create stream: Permission denied "

Would this be caused because I'm using a mythtv cvs that is a couple weeks
old by chance or a permissions problem?

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.

_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE*
http://join.msn.com/?page=features/junkmail
RE: mythweb2 having some more problems [ In reply to ]
You need to set the permission of the image_cache directory such that mythweb2 can write to it. The README explains it pretty well.

-----Original Message-----
From: Chris Germano [mailto:netslayer@hotmail.com]
Sent: Thursday, August 07, 2003 3:25 PM
To: mythtv-users@snowman.net
Subject: [mythtv-users] mythweb2 having some more problems


Thanks for the help with the htaccess, I will have to figure out how to work
with it later as it is a great idea but if included there should be some
documentation in the readme.

I'm currently running the latest mythweb2 cvs and when I click Recorded
Programs I receive the following in the preview column.

"Warning at /var/www/html/mythweb2/includes/mythbackend.php, line 190:
copy(image_cache/1244_20030807120000_20030807130000.nuv.png)
[function.copy]: failed to create stream: Permission denied "

Would this be caused because I'm using a mythtv cvs that is a couple weeks
old by chance or a permissions problem?

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.

_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE*
http://join.msn.com/?page=features/junkmail


_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
Re: mythweb2 having some more problems [ In reply to ]
> 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:

I've been getting this a lot, too. unfortunately, I have no idea what's
going on with this. the mysql_pconnect() routine is specifically
supposed to AVOID this error, by only opening as many connections as it
needs, and keeping them open, rather than opening one connection for
each page served.

I'm wondering if it has something to do with my moving the sessions
directory into the local tree (though I don't see why it would do that),
though it might also be something weird going on in mythbackend cvs (any
help guys?).

-Chris

_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
Re: mythweb2 having some more problems [ In reply to ]
> 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:

I've been getting this a lot, too. unfortunately, I have no idea what's
going on with this. the mysql_pconnect() routine is specifically
supposed to AVOID this error, by only opening as many connections as it
needs, and keeping them open, rather than opening one connection for
each page served.

I'm wondering if it has something to do with my moving the sessions
directory into the local tree (though I don't see why it would do that),
though it might also be something weird going on in mythbackend cvs (any
help guys?).

-Chris

_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
Re: mythweb2 having some more problems [ In reply to ]
On Thursday 07 August 2003 07:48 pm, Chris Petersen 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:
>
> I've been getting this a lot, too. unfortunately, I have no idea what's
> going on with this. the mysql_pconnect() routine is specifically
> supposed to AVOID this error, by only opening as many connections as it
> needs, and keeping them open, rather than opening one connection for
> each page served.
>
> I'm wondering if it has something to do with my moving the sessions
> directory into the local tree (though I don't see why it would do that),
> though it might also be something weird going on in mythbackend cvs (any
> help guys?).

May be a problem with it leaving connections open in the backend, but I
dunno... Does my recent commit doing some extra db closes help at all?

Isaac
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
Re: mythweb2 having some more problems [ In reply to ]
> May be a problem with it leaving connections open in the backend, but I
> dunno...

why open lots of database connections? Shouldn't one always-open
connection do the trick? Just buffer query output when you need to nest
loops based on query info.. then again, I'm just talking php/perl
speak here - don't know much about the C side of things.

> Does my recent commit doing some extra db closes help at all?

I'll let you know this evening if I get a chance to poke around with
it. (paying work-on-the-side coming first - I want that pvr-250 ;)

-Chris

_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
Re: mythweb2 having some more problems [ In reply to ]
On Thursday 07 August 2003 09:11 pm, Chris Petersen wrote:
> > May be a problem with it leaving connections open in the backend, but I
> > dunno...
>
> why open lots of database connections? Shouldn't one always-open
> connection do the trick? Just buffer query output when you need to nest
> loops based on query info.. then again, I'm just talking php/perl
> speak here - don't know much about the C side of things.

The mysql client lib isn't threadsafe, and neither is the part of Qt that uses
is. So, I've gotta have one connection per thread that wants to use the
database.

Isaac
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
Re: mythweb2 having some more problems [ In reply to ]
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/
Re: mythweb2 having some more problems [ In reply to ]
On 07 Aug 2003 16:48:33 -0700 Chris Petersen wrote:
> I've been getting this a lot, too. unfortunately, I have no
> idea what's
> going on with this. the mysql_pconnect() routine is specifically
> supposed to AVOID this error, by only opening as many
> connections as it
> needs, and keeping them open, rather than opening one connection for
> each page served.
>
> I'm wondering if it has something to do with my moving the sessions
> directory into the local tree (though I don't see why it
> would do that),
> though it might also be something weird going on in
> mythbackend cvs (any
> help guys?).

Chris,

I think you're mistaken on mysql_pconnect. When you use mysql_connect, the
connection is automatically closed when the script ends. The raison d'etre
of mysql_pconnect is the time it takes to build up and tear down a
connection, especially one over TCP. By caching connections indefinitely,
mysql_pconnect eliminates this overhead. No matter what the vaguely worded
PHP docs might imply, this is done on a per-child basis when using Apache.
(Apache children really have minimal communication with each other, and if
mysql_pconnect were smart enough to share cached connections over multiple
httpd processes, there'd be a configuration option for a semid or shmid, and
it would show up in /proc/sysvipc/*.)

The situation where you really want mysql_pconnect is a dedicated webserver
running a specific app. Since every request will be using the same type of
database connection, it makes sense to use mysql_pconnect. You'll end up
with the same number of PHP-initiated MySQL connections as you have Apache
children. Of course, this assumes that speed matters.

Although I don't think mythweb should use mysql_pconnect by default, it
shouldn't be causing problems like this for average myth users. It does
sound like some bug is causing another myth app to open numerous db
connections and not close them. The SHOW PROCESS statement should let you
know what process opened each connection.

Cheers,
--
Omer Shenker http://omershenker.net/
Re: Re: mythweb2 having some more problems [ In reply to ]
> I think you're mistaken on mysql_pconnect. When you use mysql_connect, the
> connection is automatically closed when the script ends.

yeah, I never said that it didn't close them. just that it did open
them. My assumption is that with the average mythweb box, there will be
one, maybe two, simultaneous connections.

> The situation where you really want mysql_pconnect is a dedicated webserver
> running a specific app. Since every request will be using the same type of
> database connection, it makes sense to use mysql_pconnect.

which is exactly what mythweb is doing. well, on most machines.

> Although I don't think mythweb should use mysql_pconnect by default, it
> shouldn't be causing problems like this for average myth users.

it's not. SHOW PROCESSLIST is showing a bunch of mythtv connections,
and no apache connections, despite the fact that I've been reloading
pages in mythweb for the past couple of minutes.

This tells me that apache is cleaning up its child threads pretty
quickly (thus, not an "indefinite" connection). The funny thing is that
the mythbackend-spawned connections started growing, and after sitting
relatively idle for the past 20 minutes, they haven't gone away.
(granted, I haven't updated to today's cvs, and Isaac says he fixed some
of this stuff).

Anyway, pconnect is NOT the problem.

-Chris

_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
RE: mythweb2 having some more problems [ In reply to ]
> On Thursday 07 August 2003 09:11 pm, Chris Petersen wrote:
> > > May be a problem with it leaving connections open in the backend,
> > > but I dunno...
> >
> > why open lots of database connections? Shouldn't one always-open
> > connection do the trick? Just buffer query output when you
> need to nest
> > loops based on query info.. then again, I'm just talking php/perl
> > speak here - don't know much about the C side of things.
>
> The mysql client lib isn't threadsafe, and neither is the
> part of Qt that uses
> is. So, I've gotta have one connection per thread that wants
> to use the
> database.
>
> Isaac
> _______________________________________________
> mythtv-users mailing list
> mythtv-users@mythtv.org
> http://mythtv.org/cgi-> bin/mailman/listinfo/mythtv-users
>

I have noticed in the MySQL process list I've had up to 10 processes
used by MythTV at a time. Usually all of them are sleeping. I also
noticed that at any given time I typically have 10 mythbackend threads
running and up to 30 mysqld threads going. I was wondering if this was
typical of a mythbackend system. I started to notice the mysqld threads
getting out of control when I started using mythweb2 a few days ago.

I've been able to get rid of this error, by setting a low value for
wait_timeout in mysql. This doesn't fix the problem, but does get rid
of the symptoms. I believe that the problem is explained in the
following:

"You are probably using a multi-process web server such as Apache. Since
database connections cannot be shared among different processes a new
one is created if the request happen to come to a different web server
child process."

I found that in the PHP docs online talking about persistent database
connections. Unfortunately I'm kind of at a loss about how to solve
this one other than switching to non-persistent connections, or setting
a low wait_timeout like I mentioned above.

-Kevin
RE: mythweb2 having some more problems [ In reply to ]
> I found that in the PHP docs online talking about persistent database
> connections. Unfortunately I'm kind of at a loss about how to solve
> this one other than switching to non-persistent connections, or setting
> a low wait_timeout like I mentioned above.

for the meantime, I've switched to mysql_connect, instead of
mysql_pconnect. I don't think this is the problem, but it's not a huge
performance issue, and maybe it will help a little.

-Chris

_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users