Tuesday, February 10, 2009

App Engine中的事务隔离级别

DataStore中的事务隔离级别介绍。
关键是这一段话:
A request that looks up an updated entity by its key at a time after Milestone A is guaranteed to see the latest version of that entity. However, if a concurrent request executes a query whose predicate (the 'where clause' for you SQL/GQL fans out there) is not satisfied by the pre-update entity but is satisfied by the post-update entity, the entity will only be part of the result set if the query executes after the commit() operation has reached Milestone B.
1。通过key来检索的查询,是肯定能获得entity的最新版本的。(当然是在MilestoneA之后,MilestoneA之前的修改对其他的查询是不可见的)
2。通过断言(就是where字句,或者构造出来的query对象)来检索的查询,有可能所出来的某些结果不满足查询条件,也有可能有些满足查询条件的结果没有被检索出来。
为什么?
因为2中的查询是通过扫描索引来检索entity的,有可能查询的时候索引还没有更新,此时扫描索引记录是满足断言的,而返回结果集的时候记录已经被更新了,此时记录不满足断言,但是结果集已经被确定,这条记录就被当作满足断言的记录返回了。

所以DataStore只对上面英文中的两种情况作保证,这就是传说中的Read Committed transaction isolation level?

Labels: ,