Optimistic concurrency control: Difference between revisions

Content deleted Content added
ClueBot (talk | contribs)
m Reverting possible vandalism by 168.99.142.100 to version by 62.178.23.32. False positive? Report it. Thanks, ClueBot. (570082) (Bot)
SAE1962 (talk | contribs)
References added & small modifications done.
Line 1:
In [[computer science]], in the field of [[database]]s, '''optimistic concurrency control''', (OCC) is a [[concurrency control]] method used in [[relational database]]s without using [[Lock (computer science)|lock]]ing. It is commonly referred to as '''optimistic locking''', a reference to the non-exclusive locks that are created on the database.
{{Unreferenced|date=February 2007}}
 
In [[computer science]], in the field of [[database]]s, '''optimistic concurrency control''', (OCC) is a [[concurrency control]] method used in [[relational database]]s without using [[Lock (computer science)|lock]]ing. It is commonly referred to as '''optimistic locking''', a reference to the non-exclusive locks that are created on the database.
 
Optimistic concurrency control is based on the assumption that most [[database transaction]]s don't conflict with other transactions, allowing OCC to be as permissive as possible in allowing transactions to execute.
Line 9 ⟶ 7:
<ol>
<li>'''Read''': The client reads values from the database, storing them to a private sandbox or cache that the client can then edit.</li>
<li>'''Validate''': When the client has completed editing of the values in its sandbox or cache, it initiates the storage of the changes back to the database. During validation, an algorithm checks if the changes to the data would conflict with either
* already-committed transactions in the case of ''backward [[validation schemesscheme]]s'', or
* currently executing transactions in the case of ''forward validation schemes''.
If a conflict exists, a conflict resolution algorithm must be used to resolve the conflict somehow (ideally by minimizing the number of changes made by the user) or, as a last resort, the entire transaction can be aborted (resulting in the loss of all changes made by the user).
Line 17 ⟶ 15:
</ol>
 
Optimistic concurrency is generally used in environments with a low contention for data. When conflicts are rare, validation can be done efficiently, leading to higher throughput than other concurrency control methods.{{Fact|date=February<ref>[http://learning.infocollections.com/ebook%202/Computer/Programming/Java/Expert_One-on-One_J2EE_Design_and_Development/6266final/LiB0080.html#450 2007}}There are two basic strategies to database concurrency: pessimistic and optimistic locking. Pessimistic locking takes the "pessimistic" view that users are highly likely to corrupt each other's data, and that the only safe option is to serialize data access, so at most one user has control of any piece of data at one time. This ensures data integrity, but can severely reduce the amount of concurrent activity the system can support.]</ref> However, if conflicts happen often, the cost of repeatedly restarting transactions hurts performance significantly; other [[non-lock concurrency control]] methods have better performance under these conditions.
 
==Web usage==
Line 28 ⟶ 26:
 
* [[MediaWiki]]'s edit pages use OCC. The conflict resolution algorithm is described [[w:Help:Edit conflict|here]].<!-- Use interwiki syntax so that mirrors can at least have a chance to pick it up -->
* [[Bugzilla]] uses OCC; conflicts are called "mid-air collisions". [http://wiki.mozilla.org/Bugzilla:FAQ:Administrative_Questions#Does_Bugzilla_provide_record_locking_when_there_is_simultaneous_access_to_the_same_bug.]
* The [[Ruby on Rails]] framework has an API for OCC. [http://api.rubyonrails.com/classes/ActiveRecord/Locking.html]
* Most [[revision control]] systems support the "merge" model for concurrency, which is OCC.
 
==References==
<div class="references" />
*{{cite journal|title=On optimistic methods for concurrency control|journal=ACM Transactions on Database Systems|date=June 1981|first=H. T.|last=Kung|coauthors=John T. Robinson|volume=6|issue=2|pages=213-226|id={{doi|10.1145/319566.319567}}}}
 
==Web links==
*{{cite journal|title=On optimistic methods for concurrency control|journal=ACM Transactions on Database Systems|date=June 1981|first=H. T.|last=Kung|coauthors=John T. Robinson|volume=6|issue=2|pages=213-226|id={{doi|10.1145/319566.319567}}}}
* Enterprise JavaBeans, 3.0, By Bill Burke, Richard Monson-Haefel, Chapter 16. Transactions, Section 16.3.5. Optimistic Locking, Publisher: O'Reilly, Pub Date: May 16, 2006,Print ISBN-10: 0-596-00978-X,
</div>
 
==See also==
*[[Opportunistic Locking]]
 
<!-- Categories -->
[[Category:concurrencyConcurrency control]]
[[Category:Software]]
 
<!-- Interwikis -->
[[fa:کنترل همروندی خوشبینانه]]
[[he:בקרת מקביליות אופטימית]]