Search Postgresql Archives

Re: Sharing database handles across forked child processes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Nov 13, 2007, at 1:18 PM, dan@xxxxxxxxx wrote:

Yep, this is a fork without exec. And the child processes often aren't
even doing any database access -- the database connection's opened and
held, then a child is forked off, and the child 'helpfully' closes the
handle during the child's global destruction phase.

What's your programming language? If it is perl using the DBI, you *must* close the handle on the child else perl's object destroy will try to close the handle by doing a shutdown on the connection, which will muck up your parent. The voodoo to make this happen is this:

 $dbh->{InactiveDestroy} = 1;
 $dbh = undef;

Also note that for some reason, this invalidates any prepared statements in the parent DBI object, so you need to make sure you don't have any, or just re-open the handle on the parent too.



---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux