|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Max pool size reached exception when trying to open a new connectioni 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 Are you sure you are not leaking connections?
-- Show quoteMiha Markic [MVP C#, INETA Country Leader for Slovenia] RightHand .NET consulting & development www.rthand.com Blog: http://cs.rthand.com/blogs/blog_with_righthand/ <ramne***@gmail.com> wrote in message news:1171294709.676296.131440@v45g2000cwv.googlegroups.com... > 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 > <ramne***@gmail.com> wrote in message
Show quote news:1171294709.676296.131440@v45g2000cwv.googlegroups.com... No it's not. Look harder.> 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. Show quote >The pool size is set to Yep. You are leaking connections. The fact that GC.Collect clears it up > 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. > makes it certain. Somewhere you are letting either a SqlConnection or an open DataReader go out of scope without closing it. David Hi i am wrapping the sqlconnection in using statement.so there is no
doubt that dispose is not getting called on sqlconnection. On Feb 12, 11:14 pm, "David Browne" <davidbaxterbrowne no potted m***@hotmail.com> wrote: Show quote > <ramne***@gmail.com> wrote in message > > news:1171294709.676296.131440@v45g2000cwv.googlegroups.com... > > > 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. > > No it's not. Look harder. > > > > > > >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. > > Yep. You are leaking connections. The fact that GC.Collect clears it up > makes it certain. Somewhere you are letting either a SqlConnection or an > open DataReader go out of scope without closing it. > > David- Hide quoted text - > > - Show quoted text - <ramne***@gmail.com> wrote in message
news:1171350745.684077.327380@m58g2000cwm.googlegroups.com... What about SqlDataReaders, are they all wrapped in using statements?> Hi i am wrapping the sqlconnection in using statement.so there is no > doubt that dispose is not getting called on sqlconnection. David I have closed the datareaders explicitly in finally block.
On Feb 13, 8:12 pm, "David Browne" <davidbaxterbrowne no potted m***@hotmail.com> wrote: Show quote > <ramne***@gmail.com> wrote in message > > news:1171350745.684077.327380@m58g2000cwm.googlegroups.com... > > > Hi i am wrapping the sqlconnection in using statement.so there is no > > doubt that dispose is not getting called on sqlconnection. > > What about SqlDataReaders, are they all wrapped in using statements? > > David |
|||||||||||||||||||||||