skip to content »

Concurrency error when deleteing or updating multiple primary key fields

concurrency error when deleteing or updating multiple primary key fields-88

Just a quick note to say the different tables within this article would benefit from borders.Look at currency problems for example: it's hard to tell which step belongs to which kind of problem.

concurrency error when deleteing or updating multiple primary key fields-83concurrency error when deleteing or updating multiple primary key fields-13

In this tutorial, we'll implement optimistic-concurrency control to handle this risk.Do not use either consistent read or a shared mode read to read the present value of the counter, because two users of the database could see the same value for the counter, and a duplicate-key error occurs if two transactions attempt to add rows with the same identifier to the is not a good solution because if two users read the counter at the same time, at least one of them ends up in deadlock when it attempts to update the counter.To implement reading and incrementing the counter, first perform a locking read of the counter using transaction that requests the same locked row must wait until the blocking transaction releases the row lock.This behavior prevents transactions from updating or deleting rows that are queried for updates by other transactions.However, waiting for a row lock to be released is not necessary if you want the query to return immediately when a requested row is locked, or if excluding locked rows from the result set is acceptable.Pessimistic concurrency is rarely used, because such locks—if not properly relinquished—can prevent other users from updating data.

For example, if a user locks a record for editing and then leaves for the day before unlocking it, no other user will be able to update that record until the original user returns and completes the update.

Borders would properly divide sections and make the whole thing a lot more easier to read.

Scott Mitchell April 2007 Summary: This is the Visual C# tutorial.

In this tutorial, we'll examine how to implement optimistic-concurrency control.

Note: We won't look at pessimistic-concurrency examples in this tutorial series.

Optimistic-concurrency control works by ensuring that the record being updated or deleted has the same values as it did when the updating or deleting process started.