Perrin Harkins scribbled on 4/12/07 11:11 PM:
> On 4/12/07, Peter Karman <[EMAIL PROTECTED]> wrote:
>> here's my (admittedly buggy) code for doing this. It caches a single 
>> dbh for
>> each unique RDB registry entry combination of domain.type.dsn. I know 
>> that it
>> breaks under mod_perl -- anyone spot why? (the error I get is from Pg: 
>> "prepared
>> statement 'dbdpg_1' already exists" after first request, because 
>> %cache seems to
>> be shared across all apache child processes).
> 
> My guess is that your code connects to the database from the parent
> process in order to do auto-discovery of the tables, and then you end
> up sharing the same handle when apache forks.  Apache::DBI does
> prevent this, so you might consider using that instead, or else add $$
> to your dbh key.  Most of what you have here is covered by either
> Apache::DBI or DBI->connect_cached, except that alarm part.
> 

yes, thanks Perrin. Thought of that myself just now (woke me up...) and saw 
your 
message. you were exactly right.

The trick was just to reset the %cache after the initialization. It's actually 
RDBO that connects to the db, regardless of the auto-discovery settings, which 
was why I ended up writing my own caching code in the first place. I wanted the 
caching to work outside Apache (so no Apache::DBI) and to use the Rose::DB DBI 
connection code (hence no DBI->connect_cached).

-- 
Peter Karman  .  http://peknet.com/  .  [EMAIL PROTECTED]

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Rose-db-object mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to