[rt.cpan.org #20648] Server side prepares fail on load-balanced web servers.

" via RT" <[email protected]>
Newsgroups gmane.comp.db.postgresql.dbdpg
Message-ID <[email protected]>
       Queue: DBD-Pg
 Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=20648 >

On Fri Aug 04 19:09:34 2006, MARKSTOS wrote:
> On Mon Jul 24 12:32:32 2006, MARKSTOS wrote:
> > Hello,
> >
> > After deploying DBD::Pg 1.48 on a load-balanced web server talking
> to
> > PostgreSQL 8.1, I saw a lot of these kind of errors:
> >
> >  prepared statement "dbdpg_7" already exists

I can't know what your exact issue is remotely, but all the times in the
past that I've encountered those errors, it has always been a case of
two seperate processes or threads sharing the same database connection
(socket), for some reason or other.

In a mod_perl situation, this could happen if your are preloading a
module at pre-fork time, and then the individual forked children are all
accessing the same connection that was created then.  The solution tends
to be to make sure you are disconnected from the database before forking
(let each child connect for itself).

If that sounds like too many connections, then you can look into any of
the available ways to pool and share connections properly - but sharing
a connection blindly via forking will always cause problems.

DBIx::Class's storage driver handles all this sort of stuff for you
(forking, threading, server disconnecting due to idle timeouts, etc),
but when using a raw DBI driver handle, you have to do this stuff yourself.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.