Deadlock via simultaneously executing UPDATE statements on a single table on SQL Server? -
i've found question: sql server deadlock between 2 update statements tell author run deadlock simultaneously executing simple update statements on single table this:
update set some_column = 'somewhat', fk = 42 -- fk constraint table id = 1 -- pk
we're assuming it's executing kind of statements, there not triggers or jobs.
i've tried variety of cases, not able reproduce it.
is ever possible? please, provide code sample.
update: code sample not reproduce issue:
setup code:
-- create tables create table b ( id int primary key ) create table ( id int primary key, b_id int not null, int_field int foreign key (b_id) references b(id) ) go -- add together info declare @i int = 0 while @i < 1000 begin insert b values (@i) insert values (@i, @i, @i) set @i = @i + 1 end
workers' code (run in @ to the lowest degree 2 sessions simultaneously):
while 1=1 update set int_field = 1, b_id = round(999 * rand(), 0) id = round(999 * rand(), 0)
sql sql-server sql-server-2008-r2 deadlock
No comments:
Post a Comment