http://qs1969.pair.com?node_id=219639


in reply to Re: Re: forking and dbi
in thread forking and dbi

There are several issues with forking and using database handles opened in the parent.

At its most basic the underlying database client libraries must support this - the Sybase libraries do, but I have heard that the Oracle libraries do not.

Second, because the client usually maintains state associated with the connection you need to make sure that no operation is pending at the time of the fork. Otherwise you are likely to have a very confused connection.

Third, DBI maintains some state as well, and this has to be taken into consideration as well.

I know for a fact that I can fork a perl script that uses Sybase::CTlib and use the connection in the child. I can even fork it multiple times and use the same connection in multiple children, as long as the use is coordinated so that only one child has access to the connection at a time (see for example my Apache::Sybase::ConPool module.)
I have not tried this with DBI, but I would expect it to work, as long as no open statements exist at the time of the fork.

Michael