Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Optimistic concurrency control
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Web usage== The [[Stateless server|stateless]] nature of [[HTTP]] makes locking infeasible for web user interfaces. It is 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 times out. [[HTTP]] does provide a form of built-in OCC. The response to an initial GET request can include an [[HTTP ETag|ETag]] for subsequent PUT requests to use in the If-Match header. Any PUT requests with an out-of-date ETag in the If-Match header can then be rejected.<ref>{{cite web | url = http://www.w3.org/1999/04/Editing/ | title = Editing the Web - Detecting the Lost Update Problem Using Unreserved Checkout | work = W3C Note | date = 10 May 1999}}</ref> Some database management systems offer OCC natively, without requiring special application code. For others, the application can implement an OCC layer outside of the database, and avoid waiting or silently overwriting records. In such cases, the [[Form (web)|form]] may include 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 invoked. ===Examples=== * [[MediaWiki]]'s edit pages use OCC.<ref>[[w:Help:Edit conflict|Help:Edit conflict]]<!-- Use interwiki syntax so that mirrors can at least have a chance to pick it up --></ref> * [[Bugzilla]] uses OCC; [[edit conflict]]s are called "mid-air collisions".<ref>{{cite web | url = https://wiki.mozilla.org/Bugzilla:FAQ#Does_Bugzilla_provide_record_locking_when_there_is_simultaneous_access_to_the_same_bug.3F_Does_the_second_person_get_a_notice_that_the_bug_is_in_use_or_how_are_they_notified.3F | title = Bugzilla: FAQ: Administrative Questions | work = MozillaWiki | date = 11 April 2012}}</ref> * The [[Ruby on Rails]] framework has an API for OCC.<ref>{{cite web | url = http://api.rubyonrails.org/classes/ActiveRecord/Locking/Optimistic.html | title = Module ActiveRecord::Locking | work = Rails Framework Documentation}}</ref> * The [[Grails (framework)|Grails]] framework uses OCC in its default conventions.<ref>{{cite web | url = http://grails.org/doc/1.0.x/guide/single.html#5.3.5%20Pessimistic%20and%20Optimistic%20Locking | title = Object Relational Mapping (GORM) | work = Grails Framework Documentation | url-status = dead | archive-url = https://web.archive.org/web/20140815173309/http://grails.org/doc/1.0.x/guide/single.html#5.3.5%20Pessimistic%20and%20Optimistic%20Locking | archive-date = 2014-08-15 }}</ref> * The [[GT.M]] database engine uses OCC for managing transactions<ref>{{cite web | url = http://tinco.pair.com/bhaskar/gtm/doc/books/pg/UNIX_manual/ch05s17.html | title = Transaction Processing | work = GT.M Programmers Guide UNIX Edition}}</ref> (even single updates are treated as mini-transactions). * [[Microsoft]]'s [[Entity Framework]] (including Code-First) has built-in support for OCC based on a binary timestamp value.<ref>{{cite web | url = https://learn.microsoft.com/en-us/ef/core/saving/concurrency?tabs=data-annotations#optimistic-concurrency | title = Handling Concurrency Conflicts | work = Entity Framework documentation hub | date = 5 July 2023}}</ref> * Most [[revision control]] systems support the "merge" model for concurrency, which is OCC.{{cn|date=February 2023}} * [[Mimer SQL]] is a [[DBMS]] that only implements optimistic concurrency control.<ref>{{cite web | url = https://developer.mimer.com/article/transaction-concurrency-optimistic-concurrency-control/ | title = Transaction Concurrency - Optimistic Concurrency Control | work = Mimer Developers - Features | access-date = 22 Dec 2023}}</ref> * [[Google App Engine]] data store uses OCC.<ref>{{cite web | url = http://code.google.com/appengine/docs/whatisgoogleappengine.html | title = The Datastore | work = What Is Google App Engine? | date = 27 August 2010}}</ref> * The [[Apache Solr]] search engine supports OCC via the {{Mono|_version_}} field.<ref>{{cite web|url=https://lucene.apache.org/solr/guide/6_6/updating-parts-of-documents.html|title=Updating Parts of Documents|access-date=2018-06-28}}</ref> * The [[Elasticsearch]] search engine updates its documents via OCC. Each version of a document is assigned a sequence number, and newer versions receive higher sequence numbers. As changes to a document arrive asynchronously, the software can use the sequence number to avoid overriding a newer version with an old one.<ref>{{cite web | title=Optimistic concurrency control | website=Elastic | url=https://www.elastic.co/guide/en/elasticsearch/reference/current/optimistic-concurrency-control.html | access-date=2024-02-05}}</ref> * [[CouchDB]] implements OCC through document revisions.<ref>{{cite web | title=Technical Overview | website=Apache CouchDB Documentation | url=https://docs.couchdb.org/en/stable/intro/overview.html | access-date=2024-02-06}}</ref> * The [[MonetDB]] [[Column-oriented DBMS|column-oriented]] [[database management system]]'s transaction management scheme is based on OCC.<ref>{{cite web | url = http://www.monetdb.org/Documentation/Manuals/SQLreference/Transactions | title = Transactions - MonetDB | date = 16 January 2013}}</ref> * Most implementations of [[software transactional memory]] use OCC.{{citation needed|reason=Claim initially said optimistic locking, now says OCC, both claims unsourced|date=March 2019}} * [[Redis]] provides OCC through WATCH command.<ref>{{cite web | url = http://redis.io/topics/transactions | title = Transactions in Redis }}</ref> * [[Firebird (database server)|Firebird]] uses [[Multiversion concurrency control|Multi-generational architecture]] as an implementation of OCC for data management.{{citation needed|date = November 2020}} * [[Amazon DynamoDB|DynamoDB]] uses conditional update as an implementation of OCC.<ref>{{cite web | url = https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithItems.html#WorkingWithItems.ConditionalUpdate| title = Working with Items and Attributes - Conditional Writes| access-date = 2 November 2020}}</ref> * [[Kubernetes]] uses OCC when updating resources.<ref>{{cite web | url = https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#resource-operations-update | title = API Overview - Resource Operations| access-date = 3 November 2020}}</ref> * [[YugabyteDB]] is a cloud-native database that primarily uses OCC.<ref>{{Cite web|last=Yugabyte|first=Team|title=Explicit locking {{!}} YugabyteDB Docs|url=https://docs.yugabyte.com/latest/architecture/transactions/explicit-locking/|access-date=2022-01-04|website=docs.yugabyte.com|language=en-us}}</ref> * [[Firestore]] is a NoSQL database by [[Firebase]] that uses OCC in its transactions. * [[Apache Iceberg]] uses OCC to update tables and run maintenance operations on them.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)