PlanetPhysics

Tuesday, August 16, 2005

A promising new turn...

In the main Noosphere module in the subroutine handler, I've replaced the connection condition block to just a simple connection. So ~ line 430 I replaced

unless ($dbh ||= dbConnect()) {
die "Couldn't open database: ",$DBI::errstr;
}
with just

$dbh = dbConnect();

I'm really not sure what ||= is suppose to do, maybe I need to test a similar expression. The following test was made

#!/usr/bin/perl

$test = -1;
unless ($test ||= connect1())
{ die "Die connect1";
}
print "After connect1\n";
print ("$test\n");
$test = -2;
unless ($test ||= connect2())
{ die "Die connect2";
}

print "After connect2\n";
print ("$test\n");

sub connect1()
{
return 1;
}
sub connect2()
{
return 0;
}

The output of running the above perl script is:

After connect1
-1
After connect2
-2

So we observe a few things. The unless statement always evaluates false. If $test is initialized to 1 then the die statement is printed.
- so what seems to happen is that an OR is evaluated on $test and on = Connect1. So if $dbh is true before the statement (so database handle is still true?) then it dies
- what is interesting is that it does not matter what connect returns, it always evaluates to false so this statement completely depends on $dbh

I'm not sure if this is the intended behavior or if it has anything to do with losing the connection with the database. I need some feedback from someone with perl wisdom. However, it seems very promising that the database connection stays 'on'.

Sunday, August 14, 2005

The mysql problem presists.

Saturday, August 13, 2005

I believe the Mysql has gone away error is now fixed. I was able to add multiple entries and edit a few. I changed line 450 in Requests.pm to

my ($rv,$sth)=dbSelect($dbh,{WHAT=>'uid,title',FROM=>$table,WHERE=>
'fulfilled is null'}); #,'ORDER BY'=>'lower(title)'});

By getting rid of the ORDER BY part everything seems ok. I figure people can live without a sorted list for now. I do not understand why this would be a problem since the actual mysql statement executes at a mysql prompt. Oh well. More testing is definately needed.

Friday, August 12, 2005

MYSQL server has gone away, Debug v1.

The current major error on PlanetPhysics is the [MYSQL server has gone away]. The user gets an internal server error, which makes the website nearly unusable. I get by using the refresh button continuously.

I've looked into the common errors associated with this on the MYSQL website, but no luck resolving it. So I've turned to the mod_perl page describing DBI connections. The first thing to check is the module and connections, so I am adding $Apache::DBI::DEBUG = 2; to the startup.pl file to start the investigation.

The first thing I notice in the log file is

[error] mod_jk child init 1 -2

after restarting apache. I must remember to look into what this means. I just realized that DEBUG=2 was already set in the Noosphere.pm. I did not get anything that looked like the mod_perl debug lines

12885 Apache::DBI need ping: yes
12885 Apache::DBI new connect to
'test::localhostPrintError=1RaiseError=0AutoCommit=1'
12885 Apache::DBI need ping: yes
12885 Apache::DBI already connected to
'test::localhostPrintError=1RaiseError=0AutoCommit=1'

I'm not sure why, but I'm on another trail now. In the DB.pm file for the dbConnect function I must have added at some time

$dbh->{'mysql_auto_reconnect'} = 1;

this might be a reason, I am commenting out now and restarting apache...
It did not help but after adding an entry I see a query error before getting the Mysql server has gone away error so I now believe it is this error that could start the cascade.

query failed, called from /var/www/pp/noosphere/lib/Noosphere/Requests.pm l
ine 450 (in Noosphere) at /var/www/pp/noosphere/lib/Noosphere/DB.pm line 28
5, line 2250.
query was [SELECT uid,title FROM requests WHERE fulfilled is null ORDER BY
lower(title)] at /var/www/pp/noosphere/lib/Noosphere/DB.pm line 286, > line 2250.


I'll test this query manually. The first thing is that the request table is empty, but why would this cause an error. Now trying the entire query. The query executes up to using lower(title). Maybe this does not work. This will need some debugging to see if lower(title) correctly works. This works so now checking call from line 450 in Requests.pm. There was no $sth->finish(). Maybe the connection isn't closed. Not sure if it matters.

Retrying the reneder and now get error:

query=INSERT INTO links VALUES (51,'objects',35,'objects')
pwd: cannot get current directory: No such file or directory

The rendering fails. Trying to rerender. It works but this is becoming a common problem. Once again this error happens before the cascade:

query failed, called from /var/www/pp/noosphere/lib/Noosphere/Requests.pm l
ine 450 (in Noosphere) at /var/www/pp/noosphere/lib/Noosphere/DB.pm line 28
5, line 2250.
query was [SELECT uid,title FROM requests WHERE fulfilled is null ORDER BY
lower(title)] at /var/www/pp/noosphere/lib/Noosphere/DB.pm line 286, > line 2250.

I will focus on this.