Re: Sharing database handles across forked child processes

Поиск
Список
Период
Сортировка
От Vivek Khera
Тема Re: Sharing database handles across forked child processes
Дата
Msg-id 80BDA488-F0B3-43A0-B5DC-D8E53A51308D@khera.org
обсуждение исходный текст
Ответ на Re: Sharing database handles across forked child processes  (dan@sidhe.org)
Список 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 по дате отправления:

Предыдущее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: Sharing database handles across forked child processes
Следующее
От: dan@sidhe.org
Дата:
Сообщение: Re: Sharing database handles across forked child processes