Content deleted Content added
No edit summary |
Web usage, with examples. |
||
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 misnomer.
Optimistic Concurrency Control is based on the assumption that [[database transaction]]s mostly don't conflict with other transactions, and that allows OCC to be as permissive as possible in allowing transactions to execute.
Line 12:
If there are few conflicts, validation can be done efficiently, and leads to better performance than other concurrency control methods. Unfortunately, if there are many conflicts, the cost of repeatedly restarting transactions, hurts performance significantly -- other [[non-lock concurrency control]] methods have better performance when there are many conflicts.
==Web usage==
The [[Stateless_server|stateless]] nature of [[HTTP]] makes locking infeasible for web user interfaces. It's common for a user to start editing a record, then leave without following a "cancel" or "logout" link. If locking is used, other users who attempt to edit the same record must wait until the first user's lock expires.
OCC is a natural choice. It is simple to implement and avoids unnecessary waiting or silently overwritten records. Typically the [[Form (web)|form]] presented to the user includes a hidden field with the record's original content, a timestamp, a sequence number, or an opaque token. On submit, this is compared against the database. If it differs, the conflict resolution algorithm is activated.
===Examples===
* [[MediaWiki]]'s edit pages use OCC. The conflict resolution algorithm is described in [[Help:Edit conflict]].
* [[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]
[[Category:concurrency control]]
|