locked
Max Pool size was reached RRS feed

  • Question

  • User408221775 posted

    Currently our application is in Windows 2003 Server. We are testing our application with 40 concurrent users using the load runner. We got the following error message.

    Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. this may have occured because all pooled connections were in use and max pool sixe was reached.

    I have used .Net Enterprise library for database operations. l am sure I have closed all database objects. In IIS Application pool properties only "Recycle worker process" alone checked for 1740 min.

    Could you please help me on this issue?

    Thanks you.

     

     

    Thursday, January 11, 2007 4:22 PM

Answers

  • User1672132137 posted

    Dear,

    as i can see through ur code, the connection isnt closing unless when an error is happening

            catch
                {
                    connection.Close();
                    throw;
                }

     

    try to put  connection.Close(); is a finally statement and run your code

      try
                {
                    return DoExecuteReader(command.Command, CommandBehavior.CloseConnection);
                }
                catch
                {
                    throw;
                }

               finally

    {

    connection.Close();

    }

    Happy Coding

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 11, 2007 5:29 PM

All replies

  • User1672132137 posted

    Dear,

    i recommend you to read the below two articles they are so informative and i used them to pass this problem before

    http://blogs.msdn.com/angelsb/archive/2004/08/25/220333.aspx

    http://webdevelopersjournal.com/columns/connection_pool.html

    Hope they can help

    Happy Coding

    Thursday, January 11, 2007 4:59 PM
  • User408221775 posted

    Thank you for reply.  we have not used using{sqlconnection} scope.  We have used enterprise library June 2005.

     I think cmdBehavior of DoExecuteReader method will close the connection.  Please give your suggestion

     


    //create a command wrapper
    DBCommandWrapper dbCommandWrapper = dbSQL.GetStoredProcCommandWrapper(sqlCommand);
    IDataReader dr = dbSQL.ExecuteReader(dbCommandWrapper);


    public virtual IDataReader ExecuteReader(DBCommandWrapper command)
            {
                IDbConnection connection = OpenConnection();
                PrepareCommand(command, connection);

                try
                {
                    return DoExecuteReader(command.Command, CommandBehavior.CloseConnection);
                }
                catch
                {
                    connection.Close();
                    throw;
                }
            }


      private IDataReader DoExecuteReader(IDbCommand command, CommandBehavior cmdBehavior)
            {
                try
                {
                    DateTime startTime = DateTime.Now;
                    IDataReader reader = command.ExecuteReader(cmdBehavior);
                    this.instrumentation.CommandExecuted(startTime);
                    return reader;
                }
                catch
                {
                    this.instrumentation.CommandFailed(command.CommandText, ConnectionStringNoCredentials);
                    throw;
                }
            }

     

    Thursday, January 11, 2007 5:21 PM
  • User1672132137 posted

    Dear,

    as i can see through ur code, the connection isnt closing unless when an error is happening

            catch
                {
                    connection.Close();
                    throw;
                }

     

    try to put  connection.Close(); is a finally statement and run your code

      try
                {
                    return DoExecuteReader(command.Command, CommandBehavior.CloseConnection);
                }
                catch
                {
                    throw;
                }

               finally

    {

    connection.Close();

    }

    Happy Coding

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 11, 2007 5:29 PM