You are here: Re: can you tell me why this causes a deadlock? « MsSQL Server « IT news, forums, messages
Re: can you tell me why this causes a deadlock?

Posted by dmarkle on 02/04/06 03:01

Joe-

Here's my attempt at an explanation.

1) Session 1 acquires a write lock on, say, a row in the table
2) Session 2 acquires a write lock on, say, a row in the table
3) Session 1 attempts to read the entire (committed) data in the table,
but is forced to
wait until Session 2 is done with its transaction because Session 2 has
a write lock on some portion of the table.
4) Session 2 attempts to read the entire (committed) data in the table,
but is forced to wait until Session 1 is done with its transaction
because Session 1 has a write lock on some portion of the table. BOOM,
you're dead in the water.

Joe Weinstein wrote:
> Hi.
>
> create table joe(c1 integer not null, c2 integer not null)
>
> Two sessions:
>
> Session 1:
> BEGIN TRAN
> insert into joe (c1,c2) values (1,2)
>
>
> Session 2:
> BEGIN TRAN
> insert into joe (c1,c2) values (3,4)
>
> Session 1:
> select * from joe
>
> Session 2:
> select * from joe
>
> One of the sessions gets a deadlock victim message.
> thanks,
> Joe

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация