sql server - Questions about DeadLock -


here, am, questions.

i fast , simple.

i work sql server 2008 , i've been facing lot of calls deadlocks.

users they're working , error

transaction (process id) deadlocked on lock resources process , has been chosen deadlock victim. rerun transaction.

so contact developers , tell them add with (no lock) in queries.

it works 100% of times.

but, right?

is there instead of it, or way rid of deadlocks?

thanks

ok. deadlock 2 processes competing same data waiting other finish before updating (or releasing lock). 1 of reasons why data locked prevent 'dirty read'. i.e. reading out-of-date data because it's been updated

so locking there reason i.e. it's there protect integrity of data. turning off (no lock) should done if sure system won't suffer result. otherwise start data corruption i.e. bad data.

i using (no lock) safe procedures report i.e. selects without following updates , have no bearing on operation of system. procedures selects , updates not good.

as per @idstam s answer, if need select data, make decisions on , updates, these need short possible. i.e. time between select , update needs short because that's time lock present , consequently window of opportunity deadlock. more prevalent in multi-user system users looking @ same data.

so, yes can turn down locking, beware can leave bad data. best thing understand deadlocking , determine if can improved. if try minimise deadlocks lowering isolation level, need use row versioning i.e. each update checks updating data last saw , if isn't (i.e. been updated in meantime) throws error.

here msdn article on how reduce deadlocks


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -