I have a C# Windows IIS server (Windows Server 2003) application connecting to an Oracle database hosted on Linux (10gR2 on Red Hat 5.3). Intermittetly, Oracle throws an ORA-3113: end-of-file on communication channel error. This screws up the OracleConnection object in C#. Then, any new OracleCommands that try to use the OracleConnection all fail saying the connection has been closed.
I have reviewed the Oracle trace files generated by this error and have isolated the problem to faulty network hardware and am working to fix it.
However, I need to make my C# code more robust and have it respond appropriately to this error by closing and not using that connection object anymore. It is easy to catch the exception in C#, but I cannot reproduce the network issue in the Development environment to prove my code works & cleans up after itself.
try
{
oracleCommand.ExecuteNonQuery();
}
catch(OracleException exception)
{
if(exception.Code == 3113)
CloseAndCleanup();
}
I have tried coding a PL/SQL trigger on a table that throws an ORA-3113 when I try to INSERT into the table.
CREATE OR REPLACE TRIGGER SCHEMA.TABLE
BEFORE DELETE OR INSERT OR UPDATE
ON SCHEMA.TABLE
FOR EACH ROW
DECLARE
CONNECTION_LOST_CONTACT EXCEPTION;
PRAGMA EXCEPTION_INIT (CONNECTION_LOST_CONTACT, -3113);
BEGIN
RAISE CONNECTION_LOST_CONTACT;
END;
This throws the right error, but doesn’t corrupt the OracleConnection object in C#. I can still send commands to the OracleConnection and it works.
How can I accurately simulate the ORA-3113 error?
ORA-3113means that a server process/thread that was assigned to a client unexpectedly died or was killed deliberately.You can produce
ORA-3113error by manually killing a server process/thread. Killing session wont produce that error.To reproduce that error you can take following steps:
1) Determine server process/thread associated with your session
On the server side
2) Use
orakill(windows) orkill -9 ..(Linux) to kill server thread/processWindows example
After that you will get the
ORA-3113on the client side.