[go: nahoru, domu]

Optimistic concurrency control: Difference between revisions

Content deleted Content added
m clean up spacing around commas and other punctuation fixes, replaced: ,P → , P
fails verification; geeksforgeeks is also a site of dubious quality; conflicts existing sources such as https://www.oreilly.com/library/view/database-systems-concepts/9788177585674/9788177585674_ch12lev1sec6.html
Line 1:
{{Short description|Concurrency control method}}
'''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.