[Catalyst] Shared database handles

Matt S Trout dbix-class at trout.me.uk
Mon May 8 01:05:41 CEST 2006


Eduardo Anuel wrote:
> I'm pretty sure that's the problem (one connection made that's shared
> by all processes) because when I'm running the application there are
> several apache processes, but a single connection to the database,
> here's an example of the errors I'm getting:
> 
> "DBD::Pg::db commit failed: ERROR:  la sentencia preparada <<dbdpg_1>>
> ya existe"
> 
> It's in spanish but I believe that the translation would be something like :
> 
> "the prepared sentence  <<dbdpg_1>> already exists"
> 
> And when that kind of error start happening there are Postgres
> processes all over the place that say "idle in transaction".
> 
> Of course it happens with a lot of other sentences, I tried using
> finish after I use a handle but that didn't solve anything, then I
> realize that the problem was the connection and tried to bring it down
> to force reconnection (just as in the example with Class DBI) but I
> haven't been able to do it in the right way.

Yeah, you're forking and failing to disconnect. The original post you 
linked is from Brandon Black, who is now a substantial DBIx::Class 
contributor and the architect of the code that makes DBIx::Class fork 
and thread-safe out of the box.

You should probably consider upgrading your Class::DBI code to use 
DBIx::Class and overriding your DBI model to get the $dbh out of the 
DBIx::Class::Storage::DBI module - if that's not currently feasible 
examine the DBIx::Class implementation and see if you can backport it 
into your own code.



More information about the Catalyst mailing list