SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Sleeping process...


Sleeping process...

Author
Message
bytezone
bytezone
SSC Journeyman
SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)

Group: General Forum Members
Points: 84 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...
Hans Lindgren
Hans Lindgren
SSCrazy
SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)

Group: General Forum Members
Points: 2794 Visits: 366
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



K. Brian Kelley
K. Brian Kelley
Keeper of the Duck
Keeper of the Duck (24K reputation)

Group: Moderators
Points: 24294 Visits: 1917
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
@‌kbriankelley
bytezone
bytezone
SSC Journeyman
SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)SSC Journeyman (84 reputation)

Group: General Forum Members
Points: 84 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...
Maqsood Ahmad
Maqsood Ahmad
SSC-Enthusiastic
SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)

Group: General Forum Members
Points: 128 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??
Attachments
activityMonitorSnapshot.JPG (108 views, 183.00 KB)
Hans Lindgren
Hans Lindgren
SSCrazy
SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)

Group: General Forum Members
Points: 2794 Visits: 366
Maqsood Ahmad:
Why do you think that SQL Server would destroy your SPIDs? Having SQL Server doing that sounds rather absurd...

Hanslindgren



Maqsood Ahmad
Maqsood Ahmad
SSC-Enthusiastic
SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)

Group: General Forum Members
Points: 128 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
Hans Lindgren
Hans Lindgren
SSCrazy
SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)

Group: General Forum Members
Points: 2794 Visits: 366
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



Maqsood Ahmad
Maqsood Ahmad
SSC-Enthusiastic
SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)

Group: General Forum Members
Points: 128 Visits: 42
Its mean then I should now be worried about it

Thanks
bitbucket-25253
bitbucket-25253
SSCoach
SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)

Group: General Forum Members
Points: 15397 Visits: 25280
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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search