[redland-dev] too many connections to mysql from php

Eric Hanson elh at cs.pdx.edu
Thu Mar 8 08:03:32 UTC 2007


On Wed, 2007-03-07 at 20:45 -0500, Gregory Williams wrote:
> On Mar 7, 2007, at 7:28 PM, Eric Hanson wrote:
> 
> > Questions include:
> > 1. How do fix the too many mysql connections errors?
> 
> I believe this can be fixed by adding a call to  
> librdf_free_query_results in your redland_fetch_array function. I'm  
> not totally sure, but give this a try, and see what happens:
> 
> 	if (librdf_query_results_finished($result)) return false;
> 
> would become something like:
> 
> 	if (librdf_query_results_finished($result)) {
> 		librdf_free_query_results($result);
> 		return false;
> 	}

Well that didn't fix the problem, but it did point me in the right
direction.  I wasn't freeing up anything.  I added a redland_disconnect
function which frees the storage, model and world.  This seems like the
correct behavior to me.

Something is still wrong though.  Now the script will work once, and
then not work again for several minutes (refuse to make storage), then
eventually work again, once, and repeat.  If I kill mysql and restart
it, it works again, once, then dies.

Here's the simplest script I could think of that behaves this way:

<?php
$REDLAND = Array ();

$REDLAND['world'] = librdf_php_get_world();
$REDLAND['storage']=librdf_new_storage
($REDLAND['world'],'mysql','aquameta',"host='localhost',database='aquameta',user='root',password=''") or die ("redland error: could not create storage");
$REDLAND['model']=librdf_new_model($REDLAND['world'],
$REDLAND['storage'], '') or die ("redland error: could not create
model");

librdf_free_model($REDLAND['model']);
librdf_free_storage($REDLAND['storage']);
librdf_free_world($REDLAND['world']);

print "done";
?>

It's not keeping any connections open:

eric at scooner:~/public_html/aquameta$ mysqladmin -u root processlist
+----+------+-----------+----+---------+------+-------+------------------+
| Id | User | Host      | db | Command | Time | State | Info
|
+----+------+-----------+----+---------+------+-------+------------------+
| 8  | root | localhost |    | Query   | 0    |       | show processlist
|
+----+------+-----------+----+---------+------+-------+------------------+
eric at scooner:~/public_html/aquameta$ 

When they were being left open this would list a growing list of
connections.

Thanks,
Eric



More information about the redland-dev mailing list