Optimistic concurrency control: Difference between revisions

Content deleted Content added
Fjerdingen (talk | contribs)
Examples: Update link Mimer SQL optimistic concurrency
m clean up spacing around commas and other punctuation fixes, replaced: ,P → , P
Line 2:
'''Optimistic concurrency control''' ('''OCC'''), also known as '''optimistic locking''', is a [[Non-lock concurrency control|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.<ref>{{cite book | title = Expert One-on-One J2EE Design and Development | first = Rohit | last = Johnson | publisher = Wrox Press | year = 2003 | isbn = 978-0-7645-4385-2 | chapter = Common Data Access Issues | chapter-url = http://learning.infocollections.com/ebook%202/Computer/Programming/Java/Expert_One-on-One_J2EE_Design_and_Development/6266final/LiB0080.html | archive-url = https://web.archive.org/web/20111008203709/http://learning.infocollections.com/ebook%202/Computer/Programming/Java/Expert_One-on-One_J2EE_Design_and_Development/6266final/LiB0080.html | archive-date = 8 October 2011}}</ref> Optimistic concurrency control was first proposed in 1979 by [[H. T. Kung]] and John T. Robinson.<ref name="KungRobinson1981">{{Cite news| title = On Optimistic Methods for Concurrency Control | first = J. T. Robinson | last = H. T. Kung | publisher = ACM Transactions on Database Systems | year = 1981 | url = https://apps.dtic.mil/dtic/tr/fulltext/u2/a081452.pdf| archive-url = https://web.archive.org/web/20190831230313/https://apps.dtic.mil/dtic/tr/fulltext/u2/a081452.pdf| url-status = live| archive-date = August 31, 2019}}</ref> The two main versions of OCC is ''[[Timestamp-based concurrency control|timestamp OCC]]'' and ''validation OCC''. Validation OCC is similar to the timestamp system except that data is recorded about the actions of transactions rather than data about database objects.<ref>{{Cite web |date=2019-06-20 |title=Validation Based Protocol in DBMS |url=https://www.geeksforgeeks.org/validation-based-protocol-in-dbms/ |access-date=2023-11-30 |website=GeeksforGeeks |language=en-US}}</ref>
 
OCC is generally used in environments with low [[Block contention|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.
 
== Phases of optimistic concurrency control ==
Line 34:
* 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.{{cncitation 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>
Line 49:
==External links==
*{{cite journal|title=On optimistic methods for concurrency control|journal=ACM Transactions on Database Systems|date=June 1981|first=H. T.|last=Kung|author2=John T. Robinson|volume=6|issue=2|pages=213–226|doi=10.1145/319566.319567|citeseerx=10.1.1.101.8988|s2cid=61600099 }}
* 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 {{ISBN|0-596-00978-X}},
* {{cite conference | first = Andreas | last = Hollmann | title = Multi-Isolation: Virtues and Limitations | book-title = Multi-Isolation (what is between pessimistic and optimistic locking) | pages = 8 | publisher = Happy-Guys Software GbR | date = May 2009 | ___location = 01069 Gutzkovstr. 30/F301.2, Dresden | url = http://www.andrej-hollmann.de/images/stories/informatik/multi-isolation-part-1.pdf | access-date = 2013-05-16 }}{{dead link|date=March 2018 |bot=InternetArchiveBot |fix-attempted=yes }}