Link to home
Start Free TrialLog in
Avatar of jssong2000
jssong2000

asked on

How to release locks on sql sever 05/08?

I have an application, after running for a while(a week or two), the sql server will slow down and make some deadlocks. But when I reboot it. It'll be better. But it will cause deadlocks again later.
 
It looks like there are locks are not released. So when I reboot the server, it becomes better because all locks are released.

My question is how to avoid this senario? Is there another way to release locks besides reboot?
For example to run a query to release....Any help or comment will be very appreciated!!!
Avatar of Chris
Chris
Flag of United Kingdom of Great Britain and Northern Ireland image

if you use activity monitor you can see the locks and kill the process assocaited with the locks - in 2008 i think its right click on the server at the top level and select activity monitor from the context menu

but you would be best off using this to track down the source of the locks to try and prevent them from happening or stop it at the source gracefully
You can kill the processes creating the situation, but its good to find the root cause and remove it. When the deadlocks happen, check in the sysprocesses or the dmv's and found out what resource it is waiting for and what other processes are using the resource. Check if you can move any of the processes during hours where they are coinciding or if some plan is taking time because of unavailability of proper index.
Can you share more information on the deadlocks and the processes running during the hours?
you can run the statement:

USE master
EXEC sp_who 'active'

and upon coming result check the colum blk does not equal to 0 and kill them with command

kill spid

this can be easily automised with a cursor
Avatar of jssong2000
jssong2000

ASKER

I have imput service, imput process service and print sevice(all window service) working at the same time. I dump 1000 input files in the imput folder every time, and I got some deadlocks. but less than 10 at most of times.

I don't get any deadlocks after reboot. But once I got deadlocks, I will get everytime later. So I feel locks are still on sql server and not released. I don't see bllk=1 if I run the following query, but I see a lot of blk= 69 and 121
USE master
EXEC sp_who 'active'

When I am testing, I see from active monitor wait time about 60,000 and wait count around 60 and cumulative wait time 420,000.

I really don't know where is the problem and how to fix it? Where to find those locks not released? they should be the culprit. I guess once I know where are they, I could run a query to release.
Thank you guys!!

if you have a specific process that it doing that then you can run a trace on that specific SPID to see what SQL it is extracting
Is there somebody know how to manually release locks on a specific table? For example run a query. Because I know I use two tables when processing. I could release those two tables' lock before processing. Thanks.
You are on a wild goose chase.  This has nothing to do with locks and everything to do with a query or queries that need to be optimized.  It does not get any simpler than that.
ASKER CERTIFIED SOLUTION
Avatar of Anuj
Anuj
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you very much! It worked.
I did some performance tuning. But fiIxing a deadlock problem is my first time.
Very appreciated!!!