Optimistic concurrency control

Optimistic concurrency control

In the field of relational database management systems, optimistic concurrency control (OCC) is a concurrency control method that assumes that multiple transactions can complete without affecting each other, and that therefore transactions can proceed without locking the data resources that they affect. Before committing, each transaction verifies that no other transaction has modified its data. If the check reveals conflicting modifications, the committing transaction rolls back.[1]

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 conflicts happen often, the cost of repeatedly restarting transactions hurts performance significantly; other concurrency control methods have better performance under these conditions.

Contents

OCC phases

More specifically, OCC transactions involve these phases:

  • Begin: Record a timestamp marking the transaction's beginning.
  • Modify: Read and write database values.
  • Validate: Check whether other transactions have modified data that this transaction has used (read or wrote). Always check transactions that completed after this transaction's start time. Optionally, check transactions that are still active at validation time.
  • Commit/Rollback: If there is no conflict, make all changes part of the official state of the database. If there is a conflict, resolve it, typically by aborting the transaction, although other resolution schemes are possible.

Web usage

The 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 times out.

HTTP does provide a form of in-built OCC, using the ETag and If-Match headers.[2]

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 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 invoked.

Examples

See also

References

  1. ^ Johnson, Rohit (2003). "Common Data Access Issues". Expert One-on-One J2EE Design and Development. Wrox Press. ISBN 0764543857. http://learning.infocollections.com/ebook%202/Computer/Programming/Java/Expert_One-on-One_J2EE_Design_and_Development/6266final/LiB0080.html. 
  2. ^ "Editing the Web - Detecting the Lost Update Problem Using Unreserved Checkout". W3C Note. 10 May 1999. http://www.w3.org/1999/04/Editing/. 
  3. ^ Help:Edit conflict
  4. ^ "Bugzilla: FAQ: Administrative Questions". MozillaWiki. 23 January 2008. https://wiki.mozilla.org/Bugzilla:FAQ:Administrative_Questions#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. 
  5. ^ "Module ActiveRecord::Locking". Rails Framework Documentation. http://api.rubyonrails.com/classes/ActiveRecord/Locking.html. 
  6. ^ "Object Relational Mapping (GORM)". Grails Framework Documentation. http://grails.org/doc/1.0.x/guide/single.html#5.3.5%20Pessimistic%20and%20Optimistic%20Locking. 
  7. ^ "Transaction Concurrency - Optimistic Concurrency Control". Mimer Developers - Features. 26 February 2010. http://developer.mimer.com/features/feature_15.htm. 
  8. ^ "The Datastore". What Is Google App Engine?. 27 August 2010. http://code.google.com/appengine/docs/whatisgoogleappengine.html. 

External links


Wikimedia Foundation. 2010.

Игры ⚽ Нужно решить контрольную?

Look at other dictionaries:

  • Optimistic Concurrency — (auch: Optimistisches Locking genannt) ist ein Verfahren, um beispielsweise in Warenwirtschaftssystemen den parallelen Zugriff von mehreren Benutzern auf denselben Datensatz konfliktarm und ohne Inkonsistenzen zu regeln. Bei der Optimistic… …   Deutsch Wikipedia

  • Concurrency control — In information technology and computer science, especially in the fields of computer programming (see also concurrent programming, parallel programming), operating systems (see also parallel computing), multiprocessors, and databases, concurrency …   Wikipedia

  • Non-lock concurrency control — In Computer Science, in the field of databases, non lock concurrency control is a concurrency control method used in relational databases without using locking. There are several non lock concurrency control methods, which involve the use of… …   Wikipedia

  • Optimistic replication — Optimistic replication[1] (also known as lazy replication[2][3]) is a strategy for replication in which replicas are allowed to diverge. Traditional pessimistic replication systems try to guarantee from the beginning that all of the replicas are… …   Wikipedia

  • Commitment ordering — In concurrency control of databases, transaction processing (transaction management), and related applications, Commitment ordering (or Commit ordering; CO; (Raz 1990, 1992, 1994, 2009)) is a class of interoperable Serializability techniques …   Wikipedia

  • Serializability — In concurrency control of databases,[1][2] transaction processing (transaction management), and various transactional applications (e.g., transactional memory[3] and software transactional memory), both centralized and distributed, a transaction… …   Wikipedia

  • Microsoft SQL Server — Developer(s) Microsoft Stable release SQL Server 2008 R2 (10.50.2500.0 Service Pack 1) / July 11, 2011; 4 months ago …   Wikipedia

  • Zeitstempelverfahren — (engl. Timestamp Ordering) werden in Datenbanksystemen eingesetzt, um die Forderung der Isolation des ACID Prinzips bei Transaktionen zu erfüllen. Zeitstempelverfahren fallen in die Kategorie der optimistischen Synchronisationsverfahren, das… …   Deutsch Wikipedia

  • Mimer SQL — is an SQL based relational database management system from the Swedish company Mimer Information Technology AB (formerly: Upright Database Technology AB), which has been developed and produced since the 1970s. The Mimer SQL database engine is… …   Wikipedia

  • Non-blocking algorithm — In computer science, a non blocking algorithm ensures that threads competing for a shared resource do not have their execution indefinitely postponed by mutual exclusion. A non blocking algorithm is lock free if there is guaranteed system wide… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”