Re: Sharing database handles across forked child processes - Mailing list pgsql-general

From Vivek Khera
Subject Re: Sharing database handles across forked child processes
Date
Msg-id 80BDA488-F0B3-43A0-B5DC-D8E53A51308D@khera.org
Whole thread Raw
In response to Re: Sharing database handles across forked child processes  (dan@sidhe.org)
List pgsql-general
On Nov 13, 2007, at 1:18 PM, dan@sidhe.org 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.



pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: Sharing database handles across forked child processes
Next
From: dan@sidhe.org
Date:
Subject: Re: Sharing database handles across forked child processes