[go: nahoru, domu]

Optimistic concurrency control: Difference between revisions

Content deleted Content added
Remove uncited speculation while retaining reference to alternatives
mention the widely-used synonym "optimistic locking" (which already redirects to this page, and is currently used in several articles)
Line 1:
'''Optimistic concurrency control''' ('''OCC'''), also known as '''optimistic locking''', is a [[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 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}}</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.