Nous avons une application utilisant le pilote IBM Informix. Chaque fois que nous essayons d'ouvrir des connexions en parallèle, nous commençons à avoir des erreurs vraiment bizarres.Can IfxConnection et le filetage s'entendent-ils?
Ceci est le code de reproduction plus petit que je pouvais venir avec:
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();
}
Selon la machine, nous courons, nous avons dû jouer un peu avec la valeur Count
pour le faire échouer, mais 10 semble reproduire l'erreur de manière cohérente.
Bien sûr, ce n'est pas du code de production, ni comment nous gérons le threading, mais cela met en évidence le problème sans introduire d'autres variables.
C'est la trace de la pile d'exception:
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()
la version IBM.Data.Informix.dll est 3.00.06000.2.
Cela a été testé sur Windows 7 (32 et 64 bits) et 2008 (64 bits).
Cela fonctionnera * probablement *, mais la pénalité liée aux performances de la désactivation du pooling est probablement trop importante. –