How can your resolve deadlocks?
Answer Posted / ilgian
Deadlocks occour when two or more processes place a lock on
the same resources and each process waits for the others to
release the lock.
The options to avoid deadlocks are basically the following:
1) always update data in the same order: if process A
updates table t1 and then table t2 and process B updates
table t2 and then table t1 deadlocks can occour. Choose an
order and use it everywhere in your code.
2) issue the commands again when you catch the deadlock
3) always update data before data selection: no other
process will place a lock on the modified records
4) identify the processes that can run with lower deadlock
priority and issue SET DEADLOCK_PRIORITY LOW before these
statements: this will tell SQLServer that the process is a
good candidate for killing in case of deadlock, having
the "important" processes free to run without kills
| Is This Answer Correct ? | 12 Yes | 0 No |
Post New Answer View All Answers
What is nonclustered index on computed columns?
How important do you consider cursors or while loops for a transactional database?
What is difference between equi join and inner join?
Do you know what are different types of replication in sql server?
What is used to replicate sessions between instances in coldfusion clusters?
What are out-of-range errors with date and time literals?
Why do we need different type of parameter?
How to rename an existing table with the "sp_rename" stored procedure in ms sql server?
Is mysql the same as sql server?
How to create database with physical files specified in ms sql server?
What is the impact on other user sessions when creating indexes?
What are different types of constraints?
Explain “@@rowcount” and “@@error” in sql server?
How to call stored procedure using http soap?
Give an example of SQL injection attack ?