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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 数据中心的变化需要更多有效冷却方式[通俗易懂]

    数据中心的变化需要更多有效冷却方式[通俗易懂]数据中心的变化需要更多有效冷却方式

    2022年4月20日
    37
  • SpringBoot整合SpringBatch

    SpringBoot整合SpringBatchSpringBatch简介SpringBatch是一个轻量级的综合性批处理框架,可用于开发企业信息系统中那些至关重要的数据批量处理业务.SpringBatch基于POJO和Spring框架,相当容易上手使用,让开发者很容易地访问和利用企业级服务.SpringBatch不是调度(scheduling)框架.因为已经有很多非常好的企业级调度框架,包括商业性质的和开源的,例如Quartz,T…

    2022年5月28日
    151
  • Linux安装nmap命令

    Linux安装nmap命令在线安装yuminstallnmap本地安装rpm软件包的安装可以使用程序rpm来完成。执行下面的命令:rpm-ivhyour-package.rpm

    2022年5月8日
    42
  • CentOS 6 命令(九)——磁盘阵列RAID

    CentOS 6 命令(九)——磁盘阵列RAIDmdadm-C/dev/md0-l5-n3/dev/sd[bcd]#创建等级为5的阵列设备md0,由sdb、sdc、sdd组成mdadm-D/dev/md0#查看阵列状态。-D查看状态pvcreate/dev/md0#将虚拟磁盘做成物理卷vgcreatenz2001_vg/dev/md0#创建卷组lvcreate-L1G-nnz2001_lv…

    2022年5月2日
    100
  • VC++ 使用BitBlt函数显示位图「建议收藏」

    VC++ 使用BitBlt函数显示位图「建议收藏」BitBlt函数该函数对指定的源设备环境区域中的像素进行位块(bit_block)转换,以传送到目标设备环境。原型:BOOLBitBlt(HDChdcDest,intnXDest,intnYDest,intnWidth,intnHeight,HDChdcSrc,intnXSrc,intnYSrc,DWORDdwRop);参数:hdcDest:指向目标设备环境的句柄。nXDe…

    2022年10月19日
    0
  • pycharm打包python项目_pycharm 打包与在线上传文件「建议收藏」

    pycharm打包python项目_pycharm 打包与在线上传文件「建议收藏」大致分为以下两部分1.本地操作将包文件按照标准格式进行规范处理、打包备份项目开发过程中:经常会涉及到备份操作常规:通过tar命令,将程序文件压缩备份较常见:可以通过系统提供的打包操作,将文件自动按照标准化格式存储2.远程操作[专门用于协同]将包文件进行标准化构建将包文件进行打包处理上传发布到网络上具体操作以下以一个例子作为说明image.png1。在包文件中,添加一个构建模块setup.pyim…

    2025年6月9日
    0

发表回复

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

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