Optimistic concurrency control transactions involve these phases:3
The 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 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.4
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 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.
Johnson, Rohit (2003). "Common Data Access Issues". Expert One-on-One J2EE Design and Development. Wrox Press. ISBN 978-0-7645-4385-2. Archived from the original on 8 October 2011. 978-0-7645-4385-2 ↩
H. T. Kung, J. T. Robinson (1981). "On Optimistic Methods for Concurrency Control" (PDF). ACM Transactions on Database Systems. Archived (PDF) from the original on August 31, 2019. https://apps.dtic.mil/dtic/tr/fulltext/u2/a081452.pdf ↩
"Editing the Web - Detecting the Lost Update Problem Using Unreserved Checkout". W3C Note. 10 May 1999. http://www.w3.org/1999/04/Editing/ ↩
Help:Edit conflict /wiki/Help:Edit_conflict ↩
"Bugzilla: FAQ: Administrative Questions". MozillaWiki. 11 April 2012. 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 ↩
"Module ActiveRecord::Locking". Rails Framework Documentation. http://api.rubyonrails.org/classes/ActiveRecord/Locking/Optimistic.html ↩
"Object Relational Mapping (GORM)". Grails Framework Documentation. Archived from the original on 2014-08-15. https://web.archive.org/web/20140815173309/http://grails.org/doc/1.0.x/guide/single.html#5.3.5%20Pessimistic%20and%20Optimistic%20Locking ↩
"Transaction Processing". GT.M Programmers Guide UNIX Edition. http://tinco.pair.com/bhaskar/gtm/doc/books/pg/UNIX_manual/ch05s17.html ↩
"Handling Concurrency Conflicts". Entity Framework documentation hub. 5 July 2023. https://learn.microsoft.com/en-us/ef/core/saving/concurrency?tabs=data-annotations#optimistic-concurrency ↩
"Transaction Concurrency - Optimistic Concurrency Control". Mimer Developers - Features. Retrieved 22 Dec 2023. https://developer.mimer.com/article/transaction-concurrency-optimistic-concurrency-control/ ↩
"The Datastore". What Is Google App Engine?. 27 August 2010. https://code.google.com/appengine/docs/whatisgoogleappengine.html ↩
"Updating Parts of Documents". Retrieved 2018-06-28. https://lucene.apache.org/solr/guide/6_6/updating-parts-of-documents.html ↩
"Optimistic concurrency control". Elastic. Retrieved 2024-02-05. https://www.elastic.co/guide/en/elasticsearch/reference/current/optimistic-concurrency-control.html ↩
"Technical Overview". Apache CouchDB Documentation. Retrieved 2024-02-06. https://docs.couchdb.org/en/stable/intro/overview.html ↩
"Transactions - MonetDB". 16 January 2013. http://www.monetdb.org/Documentation/Manuals/SQLreference/Transactions ↩
"Transactions in Redis". http://redis.io/topics/transactions ↩
"Working with Items and Attributes - Conditional Writes". Retrieved 2 November 2020. https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithItems.html#WorkingWithItems.ConditionalUpdate ↩
"API Overview - Resource Operations". Retrieved 3 November 2020. https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#resource-operations-update ↩
Yugabyte, Team. "Explicit locking | YugabyteDB Docs". docs.yugabyte.com. Retrieved 2022-01-04. https://docs.yugabyte.com/latest/architecture/transactions/explicit-locking/ ↩