Oracle – timeout period elapsed. all pooled connections were in use and max pool size reached

asp.netoraclepoolsize

After some time the following error page is shown.

What can I do to prevent this?

I have large numbers of users and the app uses Oracle 11g. Please suggest me pool size so can be extended default max pool size is 100.

I have checked all connections properly closed. I am using OracleDataReader and Datatable in my application Method that i am using is as under:

 public OracleDataReader BidNoIncr()
    {
        OracleConnection objOracleConnection = new OracleConnection(objDBClass.GetConnSring());
        OracleDataReader objDataReader;
        string strQuery = "Select max(BID_NO)+1 as SNumber from HH_BIDS";
        OracleCommand objOracleCommand = new OracleCommand(strQuery, objOracleConnection);
           objOracleConnection.Open();
           objDataReader = objOracleCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection);       
            return objDataReader;

Timeout expired. The timeout period elapsed prior to obtaining a
connection from the pool. This may have occurred because all pooled
connections were in use and max pool size was reached. Description:
An unhandled exception occurred during the execution of the current
web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Timeout expired.
The timeout period elapsed prior to obtaining a connection from the
pool. This may have occurred because all pooled connections were in
use and max pool size was reached.

Source Error: An unhandled exception was generated during the
execution of the current web request. Information regarding the origin
and location of the exception can be identified using the exception
stack trace below.

Stack Trace:

[InvalidOperationException: Timeout expired. The timeout period
elapsed prior to obtaining a connection from the pool. This may have
occurred because all pooled connections were in use and max pool size
was reached.]
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection
owningConnection) +309609
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory) +125
System.Data.OracleClient.OracleConnection.Open() +43
DbClass.GetConnSring() +58 DBViewRec.ViewSalvageItems() +53
viewsalvageitems.ShowRecords() +44
viewsalvageitems.Page_Load(Object sender, EventArgs e) +5
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object
o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender,
EventArgs e) +35 System.Web.UI.Control.OnLoad(EventArgs e) +91
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+2207

Best Answer

In general, this error may occur in the following situations:

1) You have a very large number of users using your database in the same time and you run out of free connections. Possible solutions: increase number of allowed connections on your server and/or (if your system is a webserver) increase the pool size specified in database connection string.

2) Your system has poor database logic design and/or connection leaks like when connection open isn't closed properly later. Solution for this will be auditing your code for such connection leaks and fixing them by properly closing connections all the time.