We have an application using the IBM Informix driver. Whenever we try to open connections in parallel, we begin to get some really strange errors.
This is the smallest replay code I could come up with:
const int Count = 10;
const string ConnectionString = "Host=the_host;Service=the_service;Server=the_server;Database=the_database;User ID=the_user_id;Password=the_password";
static void Main()
{
var threads = new Thread[Count];
for (var i = 0; i < threads.Length; i++)
{
threads[i] = new Thread(
number =>
{
using (var conn = new IfxConnection(ConnectionString))
{
Console.WriteLine("Opening connection {0}... ", number);
try
{
conn.Open();
Console.WriteLine("Opened connection {0}", number);
var setLockCommand = conn.CreateCommand();
setLockCommand.CommandText = "set lock mode to wait 10;";
setLockCommand.ExecuteNonQuery();
Console.WriteLine("Releasing connection {0}", number);
}
catch (IfxException ex)
{
Console.WriteLine("Failed opening connection {0}: {1}", number, ex);
}
}
});
threads[i].Start(i);
}
foreach (var thread in threads)
thread.Join();
}
Depending on which machine we are running it on, we had to play a little with the value Countto make it work, but 10 seems to reproduce the error in sequence.
Of course, this is not production code, nor the way we process threads, but this underlines the problem without entering any other variables.
This is the exception stack trace:
IBM.Data.Informix.IfxException: ERROR [HY000] [Informix .NET provider]General error.
at IBM.Data.Informix.IfxConnection.GetConnectAttr(SQL_ATTR attribute, HANDLER handler)
at IBM.Data.Informix.IfxConnection.ConnectionIsAlive()
at IBM.Data.Informix.IfxConnectionPool.BindNodeToConnection(IfxConnPoolNode poolNode, IfxConnection connection, ConnectionPoolType ConnPoolType)
at IBM.Data.Informix.IfxConnectionPool.Open(IfxConnection connection)
at IBM.Data.Informix.IfxConnPoolManager.Open(IfxConnection connection)
at IBM.Data.Informix.IfxConnection.Open()
The version of IBM.Data.Informix.dll is 3.00.06000.2.
This was tested on Windows 7 (32 and 64 bit) and in 2008 (64 bit).