|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Tuesday, August 25, 2009 9:32 AM
Points: 44,
Visits: 80
|
|
Hi,
Can anyone get back to me with tips regarding this.
I am gettign connection pool error while using the .Net application. When i checked the Activity monitor on sql server 2005, i found that many process ID where presenet with status sleeping. When i check the details for these process ID, i found the SQL query in that. I then checked the applciation which executes the query..and found the connection is closing as well as doing a dispose() even on the connectin object. Then why does the activity monitor show so many process ID with sleeping status...??What does sleeping mean..???Any link i can refer to...??How to kill these process all togetther..??Now i restart when ever this prblem occurs..!!! or mnauly kill each process
Looking forward to your suggestions..thanks...
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 7:34 AM
Points: 1,196,
Visits: 290
|
|
Hi,
First of all; if you don't have thousands of sleeping connections you shouldn't worry about it.
Sleeping means that it is, in that specific instance, not using CPU resources (amybe it will in 5 ms but not RIGHT now).
.NET usually caches it's connection because it knows how expensive it is to open a new one (if you have done .Dispose() on it .NET 'knows' that you no longer need it and the GC will take care of it in time unless a new 'compatible' connection is requested).
You can kill them manually or schedule a job (or something similar) to kill the SPIDs but I would definitly not recommend it for general use.
Regards,
Hanslindgren
|
|
|
|
|
Keeper of the Duck
Group: Moderators
Last Login: 2 days ago @ 1:13 PM
Points: 6,584,
Visits: 1,790
|
|
One thing to remember is that with pooling in effect, if you close a connection, the operating system is going to hold it open for a length of time (the default is 1 minute). It does this in case another connection request comes through with the same credentials. It'll then re-use the connection. This tends to be done for performance reasons: the connect/disconnect affects CPU/memory on both the client and SQL Server system. Of course, if the operating system needs to open more connections, it will, so you could potentially have a lot of sleeping connections and that be normal behavior over time (even though the application code explicitly closes out the connection). How long have the processes been sleeping and what is the exact error?
K. Brian Kelley, CISA, MCSE, Security+, MVP - SQL Server Regular Columnist (Security), SQLServerCentral.com Author of Introduction to SQL Server: Basic Skills for Any SQL Server User | Professional Development blog | Technical Blog | LinkedIn | Twitter
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Tuesday, August 25, 2009 9:32 AM
Points: 44,
Visits: 80
|
|
Thanks everyone for all the suggestion. May be i was looking problem at a wrong place.
I have an ASP.net application which sues SQL server 2005. After some time of its usage, users are getting error message as "Server pool reached..blah blah.." I thought this as got to do with SQl server, i guess from what i have learn so far...multiple conenctions are getting opened. I am now trying to go through each line of code to see if i am clsoing the connection.
Any tips on this...i mean how to write a data access code so that this kind of pooling problem does not happen..????
Also is there any way i can find the number of connection opened on IIS.???I mean the connection pool used..???
Thanka in advance...
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, September 07, 2009 7:12 PM
Points: 6,
Visits: 42
|
|
When I check in Activity Monitor of SQL Server 2005 I also see few connections in sleeping status. I understand if C#.NET application is using Pooling, for performance reason SQL Server does not destroy those connections for LIMITED TIME even if you have closed that connection. But what If C#.NET application is using pooling and closing connections after finishing with it but even after 6-7 days those connections are still in sleeping mode. I can tell this by Last Batch column from Activity Monitor. FYI once my application starts we don’t close that application until we have to restart our machine due to Windows updates, means our application runs for long period of time without restart. In the attached screenshot you can see that some connections were created at 27/08/2008 and their last batch was same time but even after 8 days they are still sleeping. Shouldn't they destroyed by SQL Server??
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 7:34 AM
Points: 1,196,
Visits: 290
|
|
Maqsood Ahmad: Why do you think that SQL Server would destroy your SPIDs? Having SQL Server doing that sounds rather absurd...
Hanslindgren
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, September 07, 2009 7:12 PM
Points: 6,
Visits: 42
|
|
Hanslindgren: I am just wondering that after 8 days these connection are still sleeping and might consume some resources. You think it is right behaviour of my SQL Server or my application Thanks
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 7:34 AM
Points: 1,196,
Visits: 290
|
|
Maqsood Ahmad: A sleeping connection at most cosumes a couple of KB of memory (totally neglible). If your application is not restarted then the connections will linger and save you on future connection costs (connection setups are quite expensive but leaving them open/sleeping is very very cheap). I.e. sleeping connections are not a problem in SQL Server.
Regards, Hanslindgren
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, September 07, 2009 7:12 PM
Points: 6,
Visits: 42
|
|
Its mean then I should now be worried about it
Thanks
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 12:39 PM
Points: 5,103,
Visits: 20,220
|
|
Maqsood from:
From: http://blogs.msdn.com/psssql/archive/2008/04/21/how-it-works-what-is-a-sleeping-awaiting-command-session.aspx
This issue is as old as SQL Server. In fact, it goes back to Sybase days but continues to fool and puzzle administrators.
A session with that status of sleeping / awaiting command is simply a client connection with no active query to the SQL Server. The table below shows the transitions from running to sleeping states for a session.
Connect Running Connect Completed Sleeping / Awaiting Command select @@VERSION Running select completed Sleeping / Awaiting Command
The question usually arises around a session that is holding locks and its state is sleeping / awaiting command. If the client has an open transaction and the client did not submit a commit or rollback command the state is sleeping / awaiting command.
The situation can be caused by many other variations but it is always a situation where the SQL Server is waiting for the next command from the client. Outside a physical connection problem these are always application design issues.
Hope this helps your understanding of what you have observed.
If everything seems to be going well, you have obviously overlooked something.
Ron
Please help us, help you -before posting a question please read Before posting a performance problem please read
|
|
|
|