DBI and fork

S

shurikgefter

I create a DBI connection and after that run fork() command

In the child process I close the DBI connection.

Does it affected on parent process?
 
J

J. Gleixner

I create a DBI connection and after that run fork() command

In the child process I close the DBI connection.

Does it affected on parent process?

What happened whey you tried it?

You should be able to answer that by actually taking the time
to run your code.
 
P

Peter J. Holzer

What happened whey you tried it?

You should be able to answer that by actually taking the time
to run your code.

No. If the test program crashes immediatly you know that the parent
process is affected. But what if works ok? You still don't know that a
more complex program will work, maybe under higher load.

What you should do is read perldoc DBI and search for "fork". You will
find this section:

"InactiveDestroy" (boolean)

The default value, false, means a handle will be fully destroyed as
normal when the last reference to it is removed, just as you’d expect.

If set true then the handle will be treated by the DESTROY as if it was
no longer Active, and so the database engine related effects of
DESTROYing a handle will be skipped.

Think of the name as meaning ’treat the handle as not-Active in the
DESTROY method’.

For a database handle, this attribute does not disable an explicit call
to the disconnect method, only the implicit call from DESTROY that
happens if the handle is still marked as "Active".

This attribute is specifically designed for use in Unix applications
that "fork" child processes. Either the parent or the child process,
but not both, should set "InactiveDestroy" true on all their shared
handles. (Note that some databases, including Oracle, don’t support
passing a database connection across a fork.)

hp
 
X

Xho Jingleheimerschmidt

I create a DBI connection and after that run fork() command

In the child process I close the DBI connection.

Why do you do that? Have you read the part in the docs that discuss
InactiveDestroy?
Does it affected on parent process?

Maybe, maybe not. It depends on the driver, and on what the parent
tries to do. If the parent does nothing but call POSIX:_exit, then
it probably won't be affected.

Xho
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top