Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Max pool size reached exception when trying to open a new connection

Reply
Thread Tools

Max pool size reached exception when trying to open a new connection

 
 
ramneekm@gmail.com
Guest
Posts: n/a
 
      02-12-2007
hi all,

i am working on a asp.net web app and using ado.net 's SqlClient Data
Provider to connect to
sqlserver 2005. I am getting the exception "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." . Internally i
am using a
sqldatareader to fetch data from database. The dispose of both the
reader and connection has
been called wherever they are being used. The pool size is set to
default i.e. 100. I have
tried to analyze the issue by using the sp_who2 stored procedure in
database and checking
the count of connections to the database.What is happpening is that
sometimes the pool size
limit is being maintained and increases 100. But on the other hand, it
sometimes shoot much
above the limit of 100 and then it throws the above mentioned
exception. Why does the
connection pooler sometimes enforces the pool size limit and sometimes
fails to do that
intrigues me.

But if i use GC.Collect in my code, then in that case the connection
pool limit is adhered
to and i dont get the above mentioned exception. Can someone please
help me with it and
explain why is it happening in the first place and is there a way
around it. I don't want to
use GC.Collect() in my code.

Thanks in advance
Ramneek

 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      02-12-2007
you are leaking connections. you are not always closing the connections.
you will to search your code for the bugs. having the GC will do it for
you is a bad practice. here are some rules to prevent leaking connections.

1) always use a try and finally to open/close a connection (or using).
2) never return a datareader, the opener should always close it.
3) never declaratively use a reader (from the aspx)

using a proper entity design would help prevent this.

-- bruce (sqlwork.com)



http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> hi all,
>
> i am working on a asp.net web app and using ado.net 's SqlClient Data
> Provider to connect to
> sqlserver 2005. I am getting the exception "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." . Internally i
> am using a
> sqldatareader to fetch data from database. The dispose of both the
> reader and connection has
> been called wherever they are being used. The pool size is set to
> default i.e. 100. I have
> tried to analyze the issue by using the sp_who2 stored procedure in
> database and checking
> the count of connections to the database.What is happpening is that
> sometimes the pool size
> limit is being maintained and increases 100. But on the other hand, it
> sometimes shoot much
> above the limit of 100 and then it throws the above mentioned
> exception. Why does the
> connection pooler sometimes enforces the pool size limit and sometimes
> fails to do that
> intrigues me.
>
> But if i use GC.Collect in my code, then in that case the connection
> pool limit is adhered
> to and i dont get the above mentioned exception. Can someone please
> help me with it and
> explain why is it happening in the first place and is there a way
> around it. I don't want to
> use GC.Collect() in my code.
>
> Thanks in advance
> Ramneek
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Troubleshooting Timeout expired. All pooled connections were in use and max pool size was reached. jobs ASP .Net 1 11-10-2007 02:54 AM
Error when load testing web application: all pooled connections were in use or max pool size was reached Allan Ebdrup ASP .Net 1 05-14-2007 10:43 AM
Timeout Expired...max pool size was reached. =?Utf-8?B?Sm9u?= ASP .Net 0 10-03-2006 09:05 AM
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. Guoqi Zheng ASP .Net 4 06-03-2004 06:39 PM
"max pool size was reached" problem again! Vladimir Davidov ASP .Net 1 11-20-2003 04:25 PM



Advertisments