Page 1 of 1

OraDirect threading bug

Posted: Wed 22 Aug 2007 06:30
by JerryJVL
The following code has a problem; the 'first connection' is established normally, but the 'second connection' fails with a session timeout.

This problem only occurs when opening connections on two different threads and only under OraDirect. When using ODP.NET with this same code (comment out CoreLab using clause and put in Oracle.DataAccess using clause) it works just fine.

Something inside OraDirect seems to cause a problem in this scenario.

Code: Select all

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using CoreLab.Oracle;
//using Oracle.DataAccess.Client;

namespace ConsoleApplication8
{
  class Program
  {
    static private OracleConnection _conn1;
    static private OracleConnection _conn2;
    static private string _connectionString = "User Id=pss;Password=pss;Data Source=NEMT14;Pooling=false";

    static private void Method()
    {
      Console.WriteLine("{0:HH-mm-ss}: Making second connection", DateTime.Now);
      try
      {
        _conn2 = new OracleConnection(_connectionString);
        _conn2.Open();
        Console.WriteLine("{0:HH-mm-ss}: Established second connection", DateTime.Now);
      }
      catch (Exception ex)
      {
        Console.WriteLine("{0:HH-mm-ss}: Second connection failed\n{1}", DateTime.Now, ex.ToString());
      }
    }

    static private void Runner()
    {
      while (true)
      {
        Thread.Sleep(1000);

        Method();

        Thread.Sleep(1000000);
      }
    }

    static void Main(string[] args)
    {
      Console.WriteLine("{0:HH-mm-ss}: Making first connection", DateTime.Now);
      _conn1 = new OracleConnection(_connectionString);
      _conn1.Open();
      Console.WriteLine("{0:HH-mm-ss}: Established first connection", DateTime.Now);

      Thread thread = new Thread(Runner);
      thread.IsBackground = true;
      thread.Start();

      Console.ReadLine();
    }
  }
}

OraDirect version...

Posted: Wed 22 Aug 2007 06:31
by JerryJVL
I should have mentioned as well... I'm using OraDirect 4.0.16 (latest version as far as I can tell).

Posted: Wed 22 Aug 2007 07:29
by Alexey
I can't reproduce any problem. What are your versions of Oracle server and Oracle client?

Posted: Thu 23 Aug 2007 00:03
by JerryJVL
As far as I can tell, Oracle 9i client 9.2.0.1 and server 9.2.0.6. What version of the client did you try under?

Posted: Thu 23 Aug 2007 00:08
by JerryJVL
Also note again that when I use ODP.NET to execute the exact same code it functions perfectly. When I run with OraDirect I get the following output though:

Code: Select all

10-05-38: Making first connection
10-05-40: Established first connection
10-05-41: Making second connection
10-06-53: Second connection failed
CoreLab.Oracle.OracleException: ORA-12535: TNS:operation timed out
   at CoreLab.Oracle.OracleConnection.Open()
   at ConsoleApplication8.Program.Method() in C:\NEMMCO.NET2\TmpTestApps\Console Application8\Program.cs:line 23
The problem I have is that I am trying to convince management to use OraDirect instead of ODP.NET, but it will be extremely difficult for me to make a case when OraDirect is preceived as not to work when ODP.NET does so without a flaw.

Posted: Thu 23 Aug 2007 07:06
by Alexey
I've tried this on Oracle 10g and Oracle 9.2.0.6 with Oracle client 10. No problem.
Do you experience same problem when using direct mode?
We need additional time to investigate your inquiry carefully.
Look forward to hearing from me again.

Posted: Fri 24 Aug 2007 17:21
by Alladin
Alexey, did you try to test this code on real multiprocessor box (dual/quad core)?

Posted: Mon 27 Aug 2007 08:26
by Alexey
Yes, we have tested this code on a dual core Intel box and could not reproduce any problem.

Posted: Wed 05 Sep 2007 00:16
by JerryJVL
The problem definitely exists here in our environment; I'll see if I can set up a test environment with Oracle 10 client to see if there is a difference. Even if it does make a difference I'm not sure that I can get all our servers moved to Oracle 10 though.

Again note that I am certain this is not an issue inherent in our Oracle client version though, because when I run the exact same code with ODP.NET on the exact same machine in the exact same enviromenment (even at exactly the same time as the OraDirect version!) the ODP.NET bound version succeeds and the OraDirect version fails.

I can understand it's frustrating for you that you cannot reproduce my problem. Are there any environment details (or versions) that I could provide you with that might assist in recreating the problem?

Posted: Thu 06 Sep 2007 10:15
by Alexey
Could you stop hanged process and sent me its call stack? (Mind that "Enable debug just my code" option in VS 2005 should be turned off.)
Use email address provided in the Readme.txt file.