Optimistic concurrency control
Optimistic concurrency control (OCC), also known as optimistic locking, is a non-locking concurrency control method applied to transactional systems such as relational database management systems and software transactional memory. OCC assumes that multiple transactions can frequently complete without interfering with each other. While running, transactions use data resources without acquiring locks on those resources. Before committing, each transaction verifies that no other transaction has modified the data it has read. If the check reveals conflicting modifications, the committing transaction rolls back and can be restarted. Optimistic concurrency control was first proposed in 1979 by H.... Source: e01 Encyclopedia. Licence: CC BY-SA 4.0.
Optimistic concurrency control (OCC), also known as optimistic locking, is a non-locking concurrency control method applied to transactional systems such as relational database management systems and software transactional memory. OCC assumes that multiple transactions can frequently complete without interfering with each other. While running, transactions use data resources without acquiring locks on those resources. Before committing, each transaction verifies that no other transaction has modified the data it has read. If the check reveals conflicting modifications, the committing transaction rolls back and can be restarted. Optimistic concurrency control was first proposed in 1979 by H. T. Kung and John T. Robinson. OCC is generally used in environments with low data contention. When conflicts are rare, transactions can complete without the expense of managing locks and without having transactions wait for other transactions' locks to clear, leading to higher throughput than other concurrency control methods. However, if contention for data resources is frequent, the cost of repeatedly restarting transactions hurts performance significantly, in which case other concurrency control methods may be better suited. However, locking-based ("pessimistic") methods also can deliver poor performance because locking can drastically limit effective concurrency even when deadlocks are avoided. ==Web usage== 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. 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. ===Examples=== MediaWiki's edit pages use OCC. Bugzilla uses OCC; edit conflicts are called "mid-air collisions". The Ruby on Rails framework has an API for OCC. The Grails framework uses OCC in its default conventions. The GT.M database engine uses OCC for managing transactions (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. Most revision control systems support the "merge" model for concurrency, which is OCC. Mimer SQL is a DBMS that only implements optimistic concurrency control. Google App Engine data store uses OCC. The Apache Solr search engine supports OCC via the field. 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. CouchDB implements OCC through document revisions. The MonetDB column-oriented database management system's transaction management scheme is based on OCC. Most implementations of software transactional memory use OCC. Redis provides OCC through WATCH command. Firebird uses Multi-generational architecture as an implementation of OCC for data management. DynamoDB uses conditional update as an implementation of OCC. Kubernetes uses OCC when updating resources. YugabyteDB is a cloud-native database that primarily uses OCC. 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. ==See also== Server Message Block#Opportunistic locking ==References== ==External links== 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 ,
References
- Johnson, Rohit. Expert One-on-One J2EE Design and Development . Wrox Press . 2003. · 1772060400.0
- The Datastore . What Is Google App Engine? . 27 August 2010. · 1772060400.0
- Updating Parts of Documents . retrieved 2018-06-28 · 1530140400.0
- Optimistic concurrency control . Elastic . retrieved 2024-02-05 · 1707087600.0
- Technical Overview . Apache CouchDB Documentation . retrieved 2024-02-06 · 1707174000.0
- Transactions - MonetDB . 16 January 2013. · 1772060400.0
- Transactions in Redis . · 1772060400.0
- Working with Items and Attributes - Conditional Wr . · 1772060400.0
- API Overview - Resource Operations . retrieved 3 November 2020 · 1772060400.0
- Explicit locking ! . · 1772060400.0
- On Optimistic Methods for Concurrency Control . · 1772060400.0
- *Begin: Record a timestamp marking the transaction's beginning. *Modify: Read database values, and tentatively write changes. *Validate: Check whether other transactions have modifie . · 1772060400.0
- wiki.mozilla.org . · 1772060400.0
- Module ActiveRecord::Locking . Rails Framework Documentation . · 1772060400.0
- Object Relational Mapping (GORM) . Grails Framework Documentation . · 1772060400.0
- Transaction Processing . GT.M Programmers Guide UNIX Edition . · 1772060400.0
- Handling Concurrency Conflicts . Entity Framework document . · 1772060400.0
- Transaction Concurrency - Optimistic Concurrency Control . Mimer Develop . · 1772060400.0
Cite this
"Optimistic concurrency control". 1772110736. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1340583459 JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy