如果我在同一事务中的未通知的更新之后读取,结果是什么 [英] What is the result if I read after a uncommited update within the same transaction

查看:180
本文介绍了如果我在同一事务中的未通知的更新之后读取,结果是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Google App Engine与Java JPA。
隔离级别是Serializable内部的事务;重复读取外部交易。

I'm using Google App Engine with Java JPA. The isolation level is Serializable inside transaction; Repeated Read outside transaction.

我搜索了很多文章,每个人都谈论交易之间的行为,但没有人提到在同一个交易中阅读

I search a lot of articles and everybody talks about behaviors between transactions, but no one mention about read within the same transaction.

示例:

/* data in User table with {ID=1,NAME='HANK'}  */

BEGIN;
UPDATE User SET name = 'MING' WHERE ID=1;
SELECT name FROM User WHERE ID = 1;
COMMIT;

结果:仍然{ID = 1,NAME ='HANK'}

Result : Still {ID=1, NAME='HANK'}

我的问题:


  1. 隔离级别设置是否影响同一事务中的查询?

  2. 相同交易的规则是什么?


推荐答案

在同一事务内将立即对自身可见。在您的示例中,如果您读取ID为1的行,您将看到它已更新。区别是其他用户如何受到您的事务的影响。根据您的隔离级别,其他用户可能会:

Any queries done within the same transaction will be immediately visible to itself. In your example if you read row with ID of 1, you will see that it is updated. The difference is how other users are affected by your transaction. Depending on your isolation level the other user may:


  • 获得阻止,其他用户将等到您提交/回滚

  • 读取事务之前的数据(快照隔离)

  • 读取最新的数据,即使没有提交(读取未提交) / li>
  • Get blocked, the other user will wait until you commit / rollback
  • Read the data as it was before the transaction (snapshot isolation)
  • Read the data that is most up-to-date even without you committing (read uncommitted)

我只是划破隔离级别的表面,已经有很多关于主题的书。

I'm just scratching the surface of isolation levels, there have been a lot of books written on the subject.

这篇关于如果我在同一事务中的未通知的更新之后读取,结果是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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