Re: fork() while connected

Поиск
Список
Период
Сортировка
От Doug McNaught
Тема Re: fork() while connected
Дата
Msg-id m3zo3rd0bu.fsf@varsoon.denali.to
обсуждение исходный текст
Ответ на fork() while connected  (Michael Meskes <meskes@postgresql.org>)
Ответы Re: fork() while connected  (Michael Meskes <meskes@postgresql.org>)
Список pgsql-hackers
Michael Meskes <meskes@postgresql.org> writes:

> I was just asked if there are problems if a program forks() while connected
> to the backend. Of course both processes will try to access the DB after the
> fork. Is this possible at all? If so does it create timing problems? Or
> others? I think I never tried.

This will definitely not work.  The two processes will stomp all over
each other.  They'll be sharing one socket and one backend and both
writing/reading from the socket at random times.

You can open a second connection in the child (don't close the first
one there, or it'll mess up the parent).  It's probably best to try to
avoid fork()ing with an open connection altogether.

-Doug
-- 
Let us cross over the river, and rest under the shade of the trees.  --T. J. Jackson, 1863


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Ashley Cambrell
Дата:
Сообщение: Re: LWLock contention: I think I understand the problem
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: pgbench -i spends all its time doing CHECKPOINT