What is causing "Waiting completed due to abandoned mutexes"?

I have a connection class that handles my Informix database requests. It has two functions; one for doing simple queries and one for returning data. Intermittently (especially when I let the session sit for a little, say ten minutes), I get an abandoned conn.open mutex error when requesting new information.

Here is the code in question:

public DataTable CallDtQuery(string query)
{
  DataTable dt = new DataTable();
  using (IBM.Data.Informix.IfxConnection conn = new
         IBM.Data.Informix.IfxConnection(sqlConnection))
  {
    try
    {
      IBM.Data.Informix.IfxDataAdapter adapter = new IfxDataAdapter();
      adapter.SelectCommand = new IBM.Data.Informix.IfxCommand(query, conn);
      conn.Open();  //Error location.
      adapter.Fill(dt);
      conn.Close();
    }
    catch (IBM.Data.Informix.IfxException ex)
    {
      LogError(ex, query);
      SendErrorEmail(ex, query);
      DisplayError();
    }
  }
  return dt;
}

      

Also, here's a simple query function, which is the only other function in the app that connects to the database:

public string CallSimpleQuery(string query, string command)
{
  string result = "";
  using (IBM.Data.Informix.IfxConnection conn = new
         IBM.Data.Informix.IfxConnection(sqlConnection))
  {
    try
    {
      IBM.Data.Informix.IfxDataAdapter adapter = new IfxDataAdapter();
      conn.Open();
      switch (command)
      {
        case "UPDATE":
          adapter.UpdateCommand = new IBM.Data.Informix.IfxCommand(query, conn);
          result = adapter.UpdateCommand.ExecuteNonQuery().ToString();
          break;
        case "DELETE":
          adapter.DeleteCommand = new IBM.Data.Informix.IfxCommand(query, conn);
          result = adapter.DeleteCommand.ExecuteNonQuery().ToString();
          break;
        case "SELECT":
          adapter.SelectCommand = new IBM.Data.Informix.IfxCommand(query, conn);
          result = adapter.SelectCommand.ExecuteScalar().ToString();
          break;
        case "INSERT":
          adapter.InsertCommand = new IBM.Data.Informix.IfxCommand(query, conn);
          result = adapter.InsertCommand.ExecuteNonQuery().ToString();
          break;
        }
        conn.Close();
      }
      catch (IBM.Data.Informix.IfxException ex)
      {
        LogError(ex, query);
        SendErrorEmail(ex, query);
        DisplayError();
      }
    }
    return result;
  }

      

Here is the generated error:

Error Message = The wait completed due to an abandoned mutex.
Message Source:
mscorlib
=============================
Message Target:
Boolean WaitOne(Int64, Boolean)
=============================
Stack Trace:
  at System.Threading.WaitHandle.WaitOne(Int64 timeout, Boolean exitContext)
  at System.Threading.WaitHandle.WaitOne(Int32 millisecondsTimeout, Boolean exitContext)
  at System.Threading.WaitHandle.WaitOne()
  at IBM.Data.Informix.IfxConnPoolManager.GetPool(IfxConnSettings key)
  at IBM.Data.Informix.IfxConnPoolManager.Open(IfxConnection connection)
  at IBM.Data.Informix.IfxConnection.Open()
  at XXX.Connections.CallDtQuery(String query) in d:\Inetpub\wwwroot\intranet\CWSheet-test2\App_Code\Connections.cs:line 75
  at XXX.details.Page_Load(Object sender, EventArgs e) in d:\Inetpub\wwwroot\intranet\CWSheet-test2\Details.aspx.cs:line 29
  at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
  at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
  at System.Web.UI.Control.OnLoad(EventArgs e)
  at System.Web.UI.Control.LoadRecursive()
  at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

      

When an error occurs, instead of going to the catch block and triggering the log, dispatch and display errors function, it instead ends up in the Application_Error block on global.asax. Since everything is wrapped inside a try / catch block, I'm not sure what might be causing this. Also, for some reason the application hangs on CallDtQuery. I will be flipping through the pages of posts in the form of a form and it will suddenly hang in a CallDtQuery request. Sometimes it may take a minute or two, and sometimes it will hang indefinitely until the app expires after 30 minutes.

I read a little about mutex but haven't used it before. Any mutex used is generated automatically by the ASP.NET application. With that in mind, I'm not sure how to fix this issue or fix this issue. Any suggestions?

+3


source to share


2 answers


So, it turns out that the problem is with the version of IBM.Data.Informix.dll I was using (2.90.) I found the documentation explaining the problem here: http://www.iiug.org/forums/development-tools/index.cgi / read / 109



As soon as I upgraded to a newer version (3.50) the abandoned Mutex errors disappeared. The intermittent freeze issue was also gone.

+1


source


Well, if you are not doing any weird threads, there are a few things to consider



  • Informix C # classes have some concurrency management issues (now I remember this APAR )
  • I can't tell you why, but creating a command before opening a connection seems strange.
  • I would choose the ifx command, and in particular calling Dispose in IfxConnection automatically calls Close method, maybe in double close some handles get mixed up, see this
+1


source







All Articles