可重复读取和第二次丢失更新问题 [英] repeatable read and second lost updates issue

查看:85
本文介绍了可重复读取和第二次丢失更新问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

具有可重复的读取隔离级别,仍然有可能丢失更新(第二次丢失更新问题).例如.在隔离级别设置为RR的情况下:

With repeatable read isolation level, it is still possible to lose updates (second lost updates problem). E.g. in the scenario with isolation level set to RR:

1)事务t1从r1行读取数据,

1) transaction t1 reads data from row r1,

2)事务t2从r1行读取相同的数据,

2) transaction t2 reads same data from row r1,

3)t1修改#1中读取的数据并将数据提交到r1

3) t1 modifies the data read in #1 and commits data to r1

4)t2修改#2中读取的数据并将数据提交到r1.t1的更新丢失了

4) t2 modifies the data read in #2 and commits data to r1. t1's update is lost

我使用Hibernate(将隔离级别设置为RR)进行了尝试,并看到了上述行为.

I tried this with Hibernate (isolation level set to RR) and saw the behavior as mentioned above.

那为什么为什么说通过RR隔离我们不会遇到第二次丢失更新的问题呢?

Why then is it said that with RR isolation we do not get second lost updates problem?

推荐答案

我已经在MySQL上进行了上述实验,看起来MySQL实现了RR的不同概念:

I had tried the above experiment with MySQL, and looks like MySQL implements a different notion of RR: MySQL repeatable read and lost update/phantom reads

这篇关于可重复读取和第二次丢失更新问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆