From: | Vivek Khera <vivek(at)khera(dot)org> |
---|---|
To: | PgSQL General ML <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Sharing database handles across forked child processes |
Date: | 2007-11-13 19:18:45 |
Message-ID: | 80BDA488-F0B3-43A0-B5DC-D8E53A51308D@khera.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Nov 13, 2007, at 1:18 PM, dan(at)sidhe(dot)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.
From | Date | Subject | |
---|---|---|---|
Next Message | dan | 2007-11-13 19:56:28 | Re: Sharing database handles across forked child processes |
Previous Message | Martijn van Oosterhout | 2007-11-13 18:41:23 | Re: Sharing database handles across forked child processes |