You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Joshua Spoerri <jo...@yucs.org> on 2002/02/07 21:45:45 UTC

brittleness and apache::dbi

Is there any way I can prevent my entire embperl site from falling apart
when any single page generates sql errors?

I am using Apache::DBI and DBIx::Recordset, and all my dbix objects are
created with '!Reconnect' => 1


I'll get one instance in the logs of:
[warn] [10455]ERR:  32: Line 3: Warning in Perl code:
 DBD::mysql::st execute failed: You have an error in your SQL syntax near ' acce
 ss SET a_user_name='',f_numchildren=0 WHERE (profile.id = access.a_profile_' at
 line 1 at /usr/lib/perl5/site_perl/5.6.0/DBIx/Database.pm line 150.

followed by lots of "Can't call method "Search" on an undefined value".

thanks in advance


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: brittleness and apache::dbi

Posted by Gerald Richter <ri...@ecos.de>.
> In my startup.perl, i use a module "db" which does:
>
> $db = DBIx::Database->new({
> '!DataSource'=>'dbi:mysql:mydatabase',
> '!LinkName' => 1,
> '!Reconnect' => 1,
> });
>
> *table1=DBIx::Recordset->Setup({
> '!DataSource'=>$db,
> '!Table'=>'mytable',
> });
>

You can't do this in startup.pl, because this will open the database handle
in the Apache parent process and share this database handle accross all
processes. This normaly doesn't work correctly (As you just proof on your
own).

Do the Database -> new in your startup.pl, this will read in all the
metadata and do the setup of the Recordset object inside your page (or in a
module whichyou call from your page), so you get a separate database handle
for each Apache child process. Apache::DBI will take care that the handles
are kept open.

>
> I would also prefer that an sql error in a page shouldn't even interfere
> with other invocations of that same page.
>

If you don't open the db handles in the parent process, then they will not
interfere with other invocations of that same page.


Gerald

-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: brittleness and apache::dbi

Posted by Joshua Spoerri <jo...@yucs.org>.
In my startup.perl, i use a module "db" which does:

$db = DBIx::Database->new({
'!DataSource'=>'dbi:mysql:mydatabase',
'!LinkName' => 1,
'!Reconnect' => 1,
});

*table1=DBIx::Recordset->Setup({
'!DataSource'=>$db,
'!Table'=>'mytable',
});

(and more tables, some with lengthy definitions)

Then all my pages do things like
	$db::table1->Search()

Now that I think about it, is what I'm doing subject to race conditions?
Should I instead employ a sub for each table in "db"? Will this slow me
down or take up a lot more memory?

I would also prefer that an sql error in a page shouldn't even interfere
with other invocations of that same page.


On Fri, Feb 08, 2002 at 02:43:04PM +0100, Gerald Richter wrote:
> > Is there any way I can prevent my entire embperl site from falling apart
> > when any single page generates sql errors?
> >
> 
> Normaly there shouldn't be any problems for other pages then the one that
> has the error into. At least I never have seen this, also I have sometimes
> errors in my SQL too.
> 
> Can you give a small example that shows what you are doing?
> 
> >
> > followed by lots of "Can't call method "Search" on an undefined value".
> >
> 
> That's maybe because you use the value that is return from the failing call
> as Recordset object and because of the error this value is undefined, but
> this should matter in other pages....
> 
> Gerald
> 
> 
> -------------------------------------------------------------
> Gerald Richter    ecos electronic communication services gmbh
> Internetconnect * Webserver/-design/-datenbanken * Consulting
> 
> Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
> E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
> WWW:        http://www.ecos.de      Fax:      +49 6133 925152
> -------------------------------------------------------------
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: brittleness and apache::dbi

Posted by Gerald Richter <ri...@ecos.de>.
> Is there any way I can prevent my entire embperl site from falling apart
> when any single page generates sql errors?
>

Normaly there shouldn't be any problems for other pages then the one that
has the error into. At least I never have seen this, also I have sometimes
errors in my SQL too.

Can you give a small example that shows what you are doing?

>
> followed by lots of "Can't call method "Search" on an undefined value".
>

That's maybe because you use the value that is return from the failing call
as Recordset object and because of the error this value is undefined, but
this should matter in other pages....

Gerald


-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------



---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org