tags:

views:

47

answers:

3

What are Concurrency Conflicts with regards to SQL database?

Thanks

A: 

Hi, Concurrency Conflicts occur when two transaction try to lock one resource at the database.There are many tutorials on this just use google to find some.Here is link to one link text

IordanTanev
Thanks, I tried google, got the msdn http://msdn.microsoft.com/en-us/library/dd937753(SQL.105).aspx, but couldn't understand what the concept was. Your link is a bit more helpful. Thanks
LearningCSharp
+1  A: 

I believe that transaction isolation problems (e.g. non-repeatable read, phantom read, dirty read) are at least part of what you are looking for. See more e.g. here: http://en.wikipedia.org/wiki/Isolation_%28database_systems%29

Péter Török
+1  A: 

Assume you have an SQL statement, e.g., UPDATE table SET a = a + 1 WHERE ..., which would correspond to the following code:

read a
a = a + 1
write a

Assume that two clients A and B execute this simultaneously. The following could happen (time flows from top to bottom):

   A           B
read a     
            read a
a = a + 1
write a
            a = a + 1
            write a

What happens? a is incremented only once, although it should have been incremented twice. This is a classical concurrency conflict. To avoid such conflicts, databases use transactions and locks.

Heinzi
great explanation. Thank you.
LearningCSharp