473,398 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Solving connections pool problem

I have an ASP.net application using SQL Server 2000 that every once in a
while I am getting this error:
"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"
I looked at my code and It seems that I do close every connection that I
open so I don't know why I am getting this error.
1. What is the best way to find where this problem is coming from ?
2. In order to monitor it, is there a way to print the number of free
connections in the pool (for example every time I open a new one) ?
3. Is there a way to force clearing the pool from old connections ?

Thanks for your time

ra***@hotmail.com


Nov 18 '05 #1
8 1796

"ra294" <ra***@hotmail.com> wrote in message
news:Ou**************@TK2MSFTNGP10.phx.gbl...
I have an ASP.net application using SQL Server 2000 that every once in a
while I am getting this error:
"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"
I looked at my code and It seems that I do close every connection that I
open so I don't know why I am getting this error.
1. What is the best way to find where this problem is coming from ? 2. In order to monitor it, is there a way to print the number of free
connections in the pool (for example every time I open a new one) ?
Hmm, you might check them using Enterprise Manager (Management/Current
Activity) or using a stored procedure sp_who.
3. Is there a way to force clearing the pool from old connections ?


Not that I know of. However you might instruct it (via connection string) on
how many connections to pool, etc. See
Connection Pooling for the .NET Framework Data Provider for SQL Server
..net help topic for more details.

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com
Nov 18 '05 #2
My first thought on this is that you need to use Enterprise Services (COM+)
write you data access layer in c# as service component. use a mix of JITA
and Object Pooling.
That should fix you up.

The problem is that .net depends on GC to clean up and at times even though
you are have already closed the object its may be still in memory and
waiting to GC'd
With JITA all the clients have is a proxy. If you have Object pooling
enabled on serviced components then they are returned to object pool instead
of being destroyed.
So you can have optimal performance.

Hope this helped,

Hermit Dave
"ra294" <ra***@hotmail.com> wrote in message
news:Ou**************@TK2MSFTNGP10.phx.gbl...
I have an ASP.net application using SQL Server 2000 that every once in a
while I am getting this error:
"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"
I looked at my code and It seems that I do close every connection that I
open so I don't know why I am getting this error.
1. What is the best way to find where this problem is coming from ?
2. In order to monitor it, is there a way to print the number of free
connections in the pool (for example every time I open a new one) ?
3. Is there a way to force clearing the pool from old connections ?

Thanks for your time

ra***@hotmail.com

Nov 18 '05 #3
Hi Hermit,

"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:O$**************@TK2MSFTNGP12.phx.gbl...
My first thought on this is that you need to use Enterprise Services (COM+) write you data access layer in c# as service component. use a mix of JITA
and Object Pooling.
That should fix you up.
Wow. Isn't a bit of an overkill?
The problem is that .net depends on GC to clean up and at times even though you are have already closed the object its may be still in memory and
waiting to GC'd


Yes, the objects are still there. However, when you Close connection
explicitly it is released and returned to pool.

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com
Nov 18 '05 #4
Overkill... probably yes.
But as he said before... he has closed all the connections and so in his
case... he either needs to increase the connection pool.or manage the db
layer objects more efficiently.
One of the good things bout COM+ is that it is better than .NET as such at
doing instance management. So it might be an overkill but it depends on how
responsive you want your app to be.

Regards,

Hermit Dave

PS: Just finished reading a book on COM+ and .NET... so its bound to stay
for a few days.
"Miha Markic" <miha at rthand com> wrote in message
news:eW****************@TK2MSFTNGP11.phx.gbl...
Hi Hermit,

"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:O$**************@TK2MSFTNGP12.phx.gbl...
My first thought on this is that you need to use Enterprise Services

(COM+)
write you data access layer in c# as service component. use a mix of JITA and Object Pooling.
That should fix you up.


Wow. Isn't a bit of an overkill?
The problem is that .net depends on GC to clean up and at times even

though
you are have already closed the object its may be still in memory and
waiting to GC'd


Yes, the objects are still there. However, when you Close connection
explicitly it is released and returned to pool.

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com

Nov 18 '05 #5
We have seen this question/quandary before and invariably we've found that
the connections were not getting closed while a handle to the connection was
still available. I would scour your code again looking for places where a
DataReader was passed out of a Function but the receiving class did not
close the DataReader (assuming you had CommandBehavior.CloseConnection set).

Okay, let's assume you ARE closing all of the connections. Another
possibility is that the connections are being held open so long that the
incoming ASP requests are overloading the system so new requests have to use
a new connection (instead of inheriting a dormant connection). This is
caused by slow queries, poor indexing, improper query design or a lack of
RAM (among other things) on the server.

As far as monitoring the pool, if you're using SqlClient, you can try to use
the Performance Counters generated by this provider using PerfMon.

No, going to COM+ won't solve anything. It uses the pool too...

hth

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

"ra294" <ra***@hotmail.com> wrote in message
news:Ou**************@TK2MSFTNGP10.phx.gbl...
I have an ASP.net application using SQL Server 2000 that every once in a
while I am getting this error:
"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"
I looked at my code and It seems that I do close every connection that I
open so I don't know why I am getting this error.
1. What is the best way to find where this problem is coming from ?
2. In order to monitor it, is there a way to print the number of free
connections in the pool (for example every time I open a new one) ?
3. Is there a way to force clearing the pool from old connections ?

Thanks for your time

ra***@hotmail.com

Nov 18 '05 #6
you are failing to close a connection (maybe on an error condition). tricks
to finding the cause

1) do a
dbcc inputbuffer (spid)
on connections to see a common pending command

2) set the max pool size to 1 (or whatever max concurrent connections on 1
page is), so that you will error out closer to the failed close.

-- bruce (sqlwork.com)
"ra294" <ra***@hotmail.com> wrote in message
news:Ou**************@TK2MSFTNGP10.phx.gbl...
I have an ASP.net application using SQL Server 2000 that every once in a
while I am getting this error:
"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"
I looked at my code and It seems that I do close every connection that I
open so I don't know why I am getting this error.
1. What is the best way to find where this problem is coming from ?
2. In order to monitor it, is there a way to print the number of free
connections in the pool (for example every time I open a new one) ?
3. Is there a way to force clearing the pool from old connections ?

Thanks for your time

ra***@hotmail.com

Nov 18 '05 #7
I have to side with Bruce and William

You're not closing a connection somewhere. Check your code and you'll see.

--
Eric Newton
er**@ensoft-software.com.cc (Remove the CC)
www.ensoft-software.com
C#/ASP.net Solutions developer

"bruce barker" <no***********@safeco.com> wrote in message
news:uX****************@TK2MSFTNGP10.phx.gbl...
you are failing to close a connection (maybe on an error condition). tricks to finding the cause

1) do a
dbcc inputbuffer (spid)
on connections to see a common pending command

2) set the max pool size to 1 (or whatever max concurrent connections on 1
page is), so that you will error out closer to the failed close.

-- bruce (sqlwork.com)
"ra294" <ra***@hotmail.com> wrote in message
news:Ou**************@TK2MSFTNGP10.phx.gbl...
I have an ASP.net application using SQL Server 2000 that every once in a
while I am getting this error:
"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"
I looked at my code and It seems that I do close every connection that I
open so I don't know why I am getting this error.
1. What is the best way to find where this problem is coming from ?
2. In order to monitor it, is there a way to print the number of free
connections in the pool (for example every time I open a new one) ?
3. Is there a way to force clearing the pool from old connections ?

Thanks for your time

ra***@hotmail.com


Nov 18 '05 #8
There are times in which it is not easy to tell that you are not closing a
connection. Here are the top two offenders:

1)You place connection close or dispose on a class finalizer. Never ever do
this, in fact never touch any managed objects in a finalizer, see my
comments in the docs:
http://msdn.microsoft.com/library/de...closetopic.asp
CAUTION Do not call Close or Dispose on a Connection, a DataReader, or any
other managed object in the Finalize method of your class.
2)You get an exception in your code that bypasses connection close:
con.Open()
command.Execute //Throws exception
con.Close() //does not get called, ouch!

To fix this problem always use a try finally or the using construct.
try
con.Open()
command.Execute //throws exception
finally
con.Close() //finally is guaranteed even after exception.

or the equivalent:

using (con)
con.Open()
command.Execute //throws exception
con.Close() //Close does not get called, but the using construct
guarantees a call to con.Dispose() so you are ok.

Hope this helps,
--
Angel Saenz-Badillos [MS] Managed Providers
This posting is provided "AS IS", with no warranties, and confers no
rights.Please do not send email directly to this alias.
This alias is for newsgroup purposes only.

"Eric Newton" <er**********@hotmail.com> wrote in message
news:OB**************@TK2MSFTNGP12.phx.gbl...
I have to side with Bruce and William

You're not closing a connection somewhere. Check your code and you'll see.
--
Eric Newton
er**@ensoft-software.com.cc (Remove the CC)
www.ensoft-software.com
C#/ASP.net Solutions developer

"bruce barker" <no***********@safeco.com> wrote in message
news:uX****************@TK2MSFTNGP10.phx.gbl...
you are failing to close a connection (maybe on an error condition).

tricks
to finding the cause

1) do a
dbcc inputbuffer (spid)
on connections to see a common pending command

2) set the max pool size to 1 (or whatever max concurrent connections on 1
page is), so that you will error out closer to the failed close.

-- bruce (sqlwork.com)
"ra294" <ra***@hotmail.com> wrote in message
news:Ou**************@TK2MSFTNGP10.phx.gbl...
I have an ASP.net application using SQL Server 2000 that every once in a while I am getting this error:
"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"
I looked at my code and It seems that I do close every connection that I open so I don't know why I am getting this error.
1. What is the best way to find where this problem is coming from ?
2. In order to monitor it, is there a way to print the number of free
connections in the pool (for example every time I open a new one) ?
3. Is there a way to force clearing the pool from old connections ?

Thanks for your time

ra***@hotmail.com



Nov 18 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: john bailo | last post by:
SqlConnection.Open, from a web application, threw: /Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled...
2
by: dotNET Developer | last post by:
If this forum is the wrong place to discuss this issue please point me to the right forum... We have an ASP.NET application (InterNet app) originally written in .NET 1.0 running for about 2...
6
by: DraguVaso | last post by:
Hi, I had an error concerning the connection-pool: "Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled...
17
by: Peter Proost | last post by:
Hi Group, I've got an interesting problem, I don't know if this is the right group but I think so because everything I've read about it so far says it's a .net problem. Here's the problem, we're...
2
by: Gen | last post by:
Hello there, I am developing a web application using Firebird.NET provider ver 1.7 Connection pooling is being used to better the application's performance. The problem is that the pool never...
13
by: PRP | last post by:
Hi, Our DBA has complained about the large number of connections from the aspnet_wp process. We have multiple web applications deployed in different virtual directories. I read that the way...
4
by: cj | last post by:
I have a multithreaded transaction processing app that now needs to write to a sql db. I assume I will have to make the connection in the main program and then each thread/transaction would create...
5
by: Usman Jamil | last post by:
Hi I've a class that creates a connection to a database, gets and loop on a dataset given a query and then close the connection. When I use netstat viewer to see if there is any connection open...
1
by: jobs | last post by:
Re: Troubleshooting Timeout expired. All pooled connections were in use and max pool size was reached. New webservers. win2003. IIS6. asp.net 2.0/ sql server 2005 and Oracle 9i through a 64 bit...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.