Re: can you tell me why this causes a deadlock?
- From: Joe Weinstein <joeNOSPAM@xxxxxxx>
- Date: Sat, 04 Feb 2006 14:35:25 -0800
John Rivers wrote:
if you want to do that
you need to ensure you obtain all the locks required for the whole
transaction in the first statement
That is often impossible, eg. a tx that updates two
tables. The actual requirement is that all potentially
concurrent transactions should lock needed objects in
the same order, else deadlocking is a risk.
for example:
Session 1:
BEGIN TRAN
insert into joe with (tablockx) (c1,c2) values (1,2)
Session 2:
BEGIN TRAN
insert into joe with (tablockx) (c1,c2) values (3,4)
Session 1:
select * from joe
Session 2:
select * from joe
deadlocks only occur when developers don't understand locking
and they can render a production system virtually unusable ...
Amen to that, but what I'm looking for is a description of
what two locks my original two transactions got in reverse
order.
thanks
Joe
.
- References:
- can you tell me why this causes a deadlock?
- From: Joe Weinstein
- Re: can you tell me why this causes a deadlock?
- From: Joe Weinstein
- Re: can you tell me why this causes a deadlock?
- From: John Rivers
- can you tell me why this causes a deadlock?
- Prev by Date: Re: Monthly date range substitution
- Next by Date: Re: can you tell me why this causes a deadlock?
- Previous by thread: Re: can you tell me why this causes a deadlock?
- Next by thread: Re: Views vs Stored Procedures, whats the difference?
- Index(es):
Relevant Pages
|