Optimistic vs Multi Version Concurrency Control – Differences?

Optimistic vs Multi Version Concurrency Control – Differences?

 

I am trying to find out, what the difference between optimistic concurrency control (OCC) and multi version concurrency control (MVCC) is?

So far I know that both is based on version checking for updates.

In OCC, I read about transactions that acquire no locks for reading access, only for the later update which will fail if in between the version was incremented and version checking fails. In this case the transaction will be rolled back.

In MVCC, it is basically the same, or not? Where is the difference?

 

 

I think they are sometimes used interchangeably, and if the transaction only involves one object then they are essentially the same, but MVCC is an extension of optimistic concurrency (or a version of it) that provides guarantees when more than one object is involved. Say that you have two objects, A and B, which must maintain some invariant between them, e.g. they are two numbers whose sum is constant. Now, a transaction T1 subtracts 10 from A and adds it to B, while, concurrently, another transaction T2 is reading the two numbers. Even if you optimistically update A and B independently (CAS them), T2 could get an inconsistent view of the two numbers (say, if it reads A before it’s modified but reads B after it’s been modified). MVCC would ensure T2 reads a consistent view of A and B by possibly returning their old values, i.e., it must save the old versions.

To sum up, optimistic locking (or optimistic concurrency control), is a general principle for synchronization w/o locks. MVCC is an optimistic technique which allows isolated transactions which span multiple objects.

 

转载于:https://my.oschina.net/u/138995/blog/180232

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/109964.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • mysql优化的几种方法_sgd优化算法

    mysql优化的几种方法_sgd优化算法1.SGDBatchGradientDescent在每一轮的训练过程中,BatchGradientDescent算法用整个训练集的数据计算costfuction的梯度,并用该梯度对模型参数进行更新:Θ=Θ−α⋅▽ΘJ(Θ)\Theta=\Theta-\alpha\cdot\triangledown_\ThetaJ(\Theta)优点:costfuction若为凸函数,能

    2025年8月18日
    3
  • Zigbee 协议栈

    Zigbee 协议栈Zigbee协议栈平台协议栈对我们的作用怎么使用协议栈协议栈的安装、编译与下载Components(部件)Documents(文件)Projects(项目例子)Tools(工具)平台协议TIZStack-CC2530-2.5.1a协议栈对我们的作用协议栈是协议的实现,可以理解为代码,函数库,供上层应用调用,协议较底下的层与应用是相互独立的。商业化的协议栈就是给你写好了底层的代码,符合协议标准,提供给你一个功能模块给你调用。你需要关心的就是你的应用逻辑,数据从哪里到哪里,怎么存储,处

    2022年5月28日
    35
  • Android layout属性之gravity和layout_gravity「建议收藏」

    Android layout属性之gravity和layout_gravity「建议收藏」1.gravity用来描述当前view的内容在view中的位置。gravity是控制其内容或者包含的views在该view(或viewgroup)中的位置2.layout_gravity是表示

    2022年7月3日
    22
  • QT设置活动窗口「建议收藏」

    QT设置活动窗口「建议收藏」QT设置活动窗口遇到一个QT窗口问题记录下,已经显示的窗口被其他窗口遮挡。再调用show无法将窗口激活显示到最前面。解决方式如下:if(!isActiveWindow())//判断是否是活动窗口{activateWindow();//设置成活动窗口}这样窗口就会被激活。…

    2025年8月11日
    3
  • java的三种不同注释方式

    java的三种不同注释方式注释:是一种在程序源代码中插入的不影响程序运行的文字,可以在不妨碍程序运行的同时,使得代码具有更强的可读性(提前注释好代码的作用总是比看一遍代码理解其作用来的快的),既方便自己回头修改与更新代码,也方便了他人阅读自己的代码。java中,有三种不同的注释方式:我们先写最熟悉的”HelloWorld”代码publicclassHelloWorld{ publicstatic…

    2022年7月8日
    18
  • Linux中安装Apache服务器,并进行必要的测试_怎么安装apache

    Linux中安装Apache服务器,并进行必要的测试_怎么安装apache一般Linux系统中自带apache版本,但是用这个自带的版本启动时,就会出现端口被占用等各种问题,因为自带的apache版本都比较低,所以首先查看Linux中是否已有安装的低版本的apache,如果有先卸载,然后再安装。本文用的Linux是CentOS6.5版本。一、卸载apache已安装的软件包1、命令rpm-qa|grephttpd,查看系统中…

    2022年9月21日
    2

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号