Re: URGENT: Pro*C, OCI Lda_Def and Fork Problem
Date: 2000/03/03
Message-ID: <89okdv$hip$1_at_nnrp1.deja.com>#1/1
In article <38BF29B0.A6A0AB5E_at_alcatel.com.au>,
Joe Spanicek <Joe.Spanicek_at_alcatel.com.au> wrote:
>
> Hello All,
>
> I am having problems using Pro*C OCI interface connecting to a Oracle
> database while forking processes.
>
It is not recommended or really supported to have a connection open and then do a fork() (vfork() *might* be OK but not fork()).
there are too many shared resources (files, sockets and the like) that the child and parent will end up stomping all over each other. You might have it work on version x.y.z to find it won't on version a.b.c or on OS platform "x" but not OS platform "y".
You should log off, fork, log on (or better yet, fork and then log on for the first time)
The best thing to do is to disconnect the parent process before spawning the child process. The child process can then establish its own connection to the database. When the child process finishes, the parent process can reconnect if necessary.
If the parent process and the child process must both be connected to
the database at the same time, we recommend that you fork your child
process before connecting the parent process. After forking, you
should then connect the child process using the
EXEC SQL CONNECT ... AT DBNAME ... syntax and then establish
your parent process using a different AT DBNAME clause. Any other
SQL commands after that should also use the AT DBNAME syntax to
distinguish between the parent and child process. Establishing
multiple
connections is documented in the Programmer's Guide to Oracle
Precompilers
The reason for connecting in this order is that if the parent
connects,
the process is forked, and then the parent disconnects, an ORA-03113
error will occur. Another scenario is if the parent process
establishes a
database connection, executes some SQL statements, and then spawns
a child process which also executes some SQL statements. You then
return to the parent process and try to execute another SQL statement
or a COMMITT and you get the Oracle error ORA-01012.
When you connect to the database a shadow process is started which
communicates with the user process. When you fork a new process
while connected, you end up with two user processes and only one
shadow process. The result is that the two user processes interfere
with each other. SQL*Net expects to see only one user process and
one shadow process. Sometimes forking with open connections and
sharing connections will work and sometimes it will not
[snip]
>
> Regards
>
> Joe Spanicek
>
-- Thomas Kyte tkyte_at_us.oracle.com Oracle Service Industries http://osi.oracle.com/~tkyte/index.html -- Opinions are mine and do not necessarily reflect those of Oracle Corp Sent via Deja.com http://www.deja.com/ Before you buy.Received on Fri Mar 03 2000 - 00:00:00 CET