SQL Server SLEEPING MODE , locks and transactions
I receive a regular question “What does the SQL Server sleeping state mean , and are resources locked?”
Let’s investigate .
Activity Monitor lists information about SQL Server processes. A session in the sleeping state means a client connection without an active query.
But , If a client :
1)creates a session ,
2)submits a long running transaction
3)No commit or rollback is executed
4)Client application states a query timeout of 60 seconds and the transaction hasn’t completed (or the connection is broken )
5)The SQL server session will go into a sleeping state. And maintain locks
To test , the steps above do the following –
On the SQL Server . Assuming there is a “testable”
CREATE PROCEDURE MYSPSLEEPING
AS
BEGIN TRAN
INSERT INTO testtable (ID,avalue) VALUES(1 ,'myvalue')
WAITFOR DELAY '0:5:10'--
ROLLBACK
No comments:
Post a Comment