4

I have problems Open()ing multiple OracleConnections simultaneously with multiple threads.

Example A, a single-threaded example, works fine:

for (int i = 0; i < 100; i++)
{
    OracleConnection oracon = new OracleConnection(oraconstr);
    oracon.Open();
}

(I am not closing the connections on purpose here, as I am trying to strip down the real life example where I encountered this problem)

Using netstat to check the number of actual TCP connections to the Oracle server confirms that indeed 100 connections have been established and are active after the loop has finished.

Example B does the same thing, only with multiple threads:

for (int i = 0; i < 100; i++)
{
    ThreadPool.QueueUserWorkItem(
        state =>
        {
            OracleConnection oracon = new OracleConnection(oraconstr);
            oracon.Open();
        });
    // Thread.Sleep(100);
}

In the multi-threaded case, netstat shows only one active TCP connection, and except for the lucky first thread to win the "Open() race", all other threads are blocked on their call to Open(), and after 15 seconds, which is the Connection Timeout, odp.net will finally throw

Oracle.DataAccess.Client.OracleException Connection request timed out

exceptions and also throw this native exception, which will make the app actually crash:

ORA-24550: signal received: Unhandled exception: Code=e0434f4d Flags=1

kpedbg_dmp_stack()+428<-kpeDbgCrash()+102<-kpeDbgSignalHandler()+123<-skgesig_Win_UnhandledExceptionFilter()+173<-0000000077A49380<-0000000077B6573C<-0000000077AE5148<-0000000077B0554D<-0000
000077AE5D1C<-0000000077AE62EE<-000007FEFDD7AA7D<-000007FEE7E6F0BD<-000007FEE8422ED0<-000007FF001AB805<-000000000268A4B8<-00000000FFFFFC18

If I comment in the Thread.Sleep statement above, everything's fine. I tried 50ms, but that wasn't enough. Doing a 100ms sleep before every OracleConnection.Open(), just in case, is obviously not a performant solution.

Any idea what's going on here and how to fix or work around this? (Other than of course talking to Oracle directly, which I'll try to do once I've posted this question)

This is .net 3.5, using Oracle.DataAccess.dll version 2.112.1.0. I also tested 2.112.3.0 - same result.

Fwiw, google says there are other people with the same .net exception like this one, which might be related.

Evgeniy Berezovsky
  • 18,571
  • 13
  • 82
  • 156

0 Answers0