appengine 1.6.4 DataNucleus将-的AppEngine-2.0.0 datanucleus cache 3.0.1
大家好
我使用datanucleus 2级缓存从读取查询返回过时数据。
我的持久配置没有缓存设置,所以从文档中它使用默认设置。
问题
第1步: 在TX1中对实体MerchantPromotion(5)进行简单合并。
结果1: 数据存储区查看器显示实体已正确更新。
第2步: 在TX2中读取实体MerchantPromotion(5)。
结果2: 返回的数据是预合并的数据而不是更改的数据。
它似乎与二级缓存有关,因为当二级缓存设置为NONE时,操作成功。
附加了DN跟踪。
任何帮助表示感谢。
-lp
<persistence-unit name="transactions-optional">
<provider>org.datanucleus.api.jpa.PersistenceProviderImpl</provider>
<properties>
<property name="datanucleus.ConnectionURL" value="appengine"/>
<property name="datanucleus.metadata.allowLoadAtRuntime" value="true"/>
<property name="datanucleus.appengine.ignorableMetaDataBehavior" value="ERROR"/>
<property name="datanucleus.DetachAllOnCommit" value="true" />
<property name="datanucleus.DetachOnClose" value="true" />
<property name="datanucleus.appengine.datastoreEnableXGTransactions" value="true"/>
</properties>
</persistence-unit>
合并现有实体
07/05/2012 11:00:43 PM com.asteriski.mingle.venueportal.managedbeans.PromotionBackingBean saveAction
INFO: saveSun May 06 00:00:00 UTC 2012
07/05/2012 11:00:43 PM org.datanucleus.ObjectManagerImpl initialiseLevel1Cache
FINE: Level 1 Cache of type "soft" initialised
07/05/2012 11:00:43 PM com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl$DatastoreManagedConnection <init>
FINE: Created ManagedConnection using DatastoreService = com.google.appengine.api.datastore.DatastoreServiceImpl@136fb9fd
07/05/2012 11:00:43 PM org.datanucleus.store.connection.ConnectionManagerImpl allocateConnection
FINE: Connection added to the pool : com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl$DatastoreManagedConnection@47d77d9e for key=org.datanucleus.ObjectManagerImpl@1f4790be in factory=ConnectionFactory:tx[com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl@7fac4f3e]
07/05/2012 11:00:43 PM com.asteriski.mingle.venueportal.service.PromotionService save
INFO: com.asteriski.mingle.venueportal.beans.PromotionBean@147834eb
07/05/2012 11:00:43 PM com.asteriski.mingle.venueportal.dao.PromotionDAO save
INFO: content:another one here11
07/05/2012 11:00:43 PM org.datanucleus.ObjectManagerImpl putObjectIntoCache
FINE: Object "com.asteriski.mingle.venueportal.entity.MerchantPromotion@6ac1abcf" (id="org.datanucleus.identity.IdentityReference@20e74663") added to Level 1 cache (loadedFlags="[YYYYYYYYYY]")
07/05/2012 11:00:43 PM org.datanucleus.store.connection.ConnectionManagerImpl allocateConnection
FINE: Connection found in the pool : com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl$DatastoreManagedConnection@47d77d9e for key=org.datanucleus.ObjectManagerImpl@1f4790be in factory=ConnectionFactory:tx[com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl@7fac4f3e]
07/05/2012 11:00:43 PM org.datanucleus.store.connection.ConnectionManagerImpl allocateConnection
FINE: Connection found in the pool : com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl$DatastoreManagedConnection@47d77d9e for key=org.datanucleus.ObjectManagerImpl@1f4790be in factory=ConnectionFactory:tx[com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl@7fac4f3e]
07/05/2012 11:00:43 PM org.datanucleus.store.connection.ConnectionManagerImpl allocateConnection
FINE: Connection found in the pool : com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl$DatastoreManagedConnection@47d77d9e for key=org.datanucleus.ObjectManagerImpl@1f4790be in factory=ConnectionFactory:tx[com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl@7fac4f3e]
07/05/2012 11:00:43 PM org.datanucleus.store.connection.ConnectionManagerImpl allocateConnection
FINE: Connection found in the pool : com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl$DatastoreManagedConnection@47d77d9e for key=org.datanucleus.ObjectManagerImpl@1f4790be in factory=ConnectionFactory:tx[com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl@7fac4f3e]
07/05/2012 11:00:43 PM org.datanucleus.store.connection.ConnectionManagerImpl allocateConnection
FINE: Connection found in the pool : com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl$DatastoreManagedConnection@47d77d9e for key=org.datanucleus.ObjectManagerImpl@1f4790be in factory=ConnectionFactory:tx[com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl@7fac4f3e]
07/05/2012 11:00:43 PM org.datanucleus.ObjectManagerImpl replaceObjectId
FINE: Object "com.asteriski.mingle.venueportal.entity.MerchantPromotion@6ac1abcf" (id="org.datanucleus.identity.IdentityReference@20e74663") being changed to be referenced by id="com.asteriski.mingle.venueportal.entity.MerchantPromotion:MerchantPromotion(5)" in Level 1 cache
07/05/2012 11:00:43 PM org.datanucleus.ObjectManagerImpl putObjectIntoCache
FINE: Object "com.asteriski.mingle.venueportal.entity.MerchantPromotion@6ac1abcf" (id="com.asteriski.mingle.venueportal.entity.MerchantPromotion:MerchantPromotion(5)") added to Level 1 cache (loadedFlags="[YYYYYYYYYY]")
07/05/2012 11:00:43 PM org.datanucleus.store.connection.ConnectionManagerImpl allocateConnection
FINE: Connection found in the pool : com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl$DatastoreManagedConnection@47d77d9e for key=org.datanucleus.ObjectManagerImpl@1f4790be in factory=ConnectionFactory:tx[com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl@7fac4f3e]
07/05/2012 11:00:43 PM org.datanucleus.ObjectManagerImpl performLevel2CacheUpdateAtCommit
FINE: Object with id="org.datanucleus.identity.IdentityReference@20e74663" removed from Level 2 cache since was updated yet object has been GCed
07/05/2012 11:00:43 PM org.datanucleus.store.connection.ConnectionManagerImpl$1 managedConnectionPostClose
FINE: Connection removed from the pool : com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl$DatastoreManagedConnection@47d77d9e for key=org.datanucleus.ObjectManagerImpl@1f4790be in factory=ConnectionFactory:tx[com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl@7fac4f3e]
07/05/2012 11:00:43 PM org.datanucleus.state.LifeCycleState changeState
FINE: Object "com.asteriski.mingle.venueportal.entity.MerchantPromotion@6ac1abcf" (id="com.asteriski.mingle.venueportal.entity.MerchantPromotion:MerchantPromotion(5)") has a lifecycle change : "P_NEW"->"DETACHED_CLEAN"
07/05/2012 11:00:43 PM org.datanucleus.ObjectManagerImpl removeObjectFromCache
FINE: Object with id="com.asteriski.mingle.venueportal.entity.MerchantPromotion:MerchantPromotion(5)" being removed from Level 1 cache [current cache size = 1]
07/05/2012 11:00:43 PM org.datanucleus.ObjectManagerImpl disconnectSMCache
FINE: Level 1 Cache cleared
读实体
07/05/2012 11:00:43 PM com.google.appengine.datanucleus.query.JPQLQuery performExecute
FINE: JPQL Query : Execution Time = 6 ms
07/05/2012 11:00:43 PM org.datanucleus.ObjectManagerImpl getObjectFromCache
FINE: Object with id "com.asteriski.mingle.venueportal.entity.MerchantPromotion:MerchantPromotion(3)" not found in Level 1 cache [cache size = 0]
07/05/2012 11:00:43 PM org.datanucleus.ObjectManagerImpl getObjectFromCache
FINE: Object with id="com.asteriski.mingle.venueportal.entity.MerchantPromotion:MerchantPromotion(3)" taken from Level 2 cache (loadedFlags="[YYYYYYYYYY]", relationFields="null") - extracting into managed persistable object
07/05/2012 11:00:43 PM org.datanucleus.ObjectManagerImpl putObjectIntoCache
FINE: Object "com.asteriski.mingle.venueportal.entity.MerchantPromotion@1aa3c177" (id="com.asteriski.mingle.venueportal.entity.MerchantPromotion:MerchantPromotion(3)") added to Level 1 cache (loadedFlags="[NNNYNNNNNN]")
07/05/2012 11:00:43 PM org.datanucleus.ObjectManagerImpl getObjectFromCache
FINE: Object with id="com.asteriski.mingle.venueportal.entity.MerchantPromotion:MerchantPromotion(3)" taken from Level 2 cache represented as "com.asteriski.mingle.venueportal.entity.MerchantPromotion@1aa3c177"
07/05/2012 11:00:43 PM org.datanucleus.state.LifeCycleState changeState
FINE: Object "com.asteriski.mingle.venueportal.entity.MerchantPromotion@1aa3c177" (id="com.asteriski.mingle.venueportal.entity.MerchantPromotion:MerchantPromotion(3)") has a lifecycle change : "P_CLEAN"->"P_NONTRANS"
07/05/2012 11:00:43 PM org.datanucleus.store.connection.ConnectionManagerImpl allocateConnection
FINE: Connection found in the pool : com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl$DatastoreManagedConnection@230cc23b for key=org.datanucleus.ObjectManagerImpl@2db1d931 in factory=ConnectionFactory:tx[com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl@7fac4f3e]
07/05/2012 11:00:43 PM com.asteriski.mingle.venueportal.service.PromotionService find
INFO: published:MerchantLocation does not exist
07/05/2012 11:00:43 PM org.datanucleus.ObjectManagerImpl getObjectFromCache
FINE: Object with id "com.asteriski.mingle.venueportal.entity.MerchantPromotion:MerchantPromotion(4)" not found in Level 1 cache [cache size = 1]
07/05/2012 11:00:43 PM org.datanucleus.ObjectManagerImpl getObjectFromCache
FINE: Object with id="com.asteriski.mingle.venueportal.entity.MerchantPromotion:MerchantPromotion(4)" taken from Level 2 cache (loadedFlags="[YYYYYYYYYY]", relationFields="null") - extracting into managed persistable object
07/05/2012 11:00:43 PM org.datanucleus.ObjectManagerImpl putObjectIntoCache
FINE: Object "com.asteriski.mingle.venueportal.entity.MerchantPromotion@74f2794a" (id="com.asteriski.mingle.venueportal.entity.MerchantPromotion:MerchantPromotion(4)") added to Level 1 cache (loadedFlags="[NNNYNNNNNN]")
07/05/2012 11:00:43 PM org.datanucleus.ObjectManagerImpl getObjectFromCache
FINE: Object with id="com.asteriski.mingle.venueportal.entity.MerchantPromotion:MerchantPromotion(4)" taken from Level 2 cache represented as "com.asteriski.mingle.venueportal.entity.MerchantPromotion@74f2794a"
07/05/2012 11:00:43 PM org.datanucleus.state.LifeCycleState changeState
FINE: Object "com.asteriski.mingle.venueportal.entity.MerchantPromotion@74f2794a" (id="com.asteriski.mingle.venueportal.entity.MerchantPromotion:MerchantPromotion(4)") has a lifecycle change : "P_CLEAN"->"P_NONTRANS"
07/05/2012 11:00:43 PM org.datanucleus.store.connection.ConnectionManagerImpl allocateConnection
FINE: Connection found in the pool : com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl$DatastoreManagedConnection@230cc23b for key=org.datanucleus.ObjectManagerImpl@2db1d931 in factory=ConnectionFactory:tx[com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl@7fac4f3e]
07/05/2012 11:00:43 PM com.asteriski.mingle.venueportal.service.PromotionService find
INFO: published:MerchantLocation does not exist
07/05/2012 11:00:43 PM org.datanucleus.ObjectManagerImpl getObjectFromCache
FINE: Object with id "com.asteriski.mingle.venueportal.entity.MerchantPromotion:MerchantPromotion(5)" not found in Level 1 cache [cache size = 2]
07/05/2012 11:00:43 PM org.datanucleus.ObjectManagerImpl getObjectFromCache
FINE: Object with id="com.asteriski.mingle.venueportal.entity.MerchantPromotion:MerchantPromotion(5)" taken from Level 2 cache (loadedFlags="[YYYYYYYYYY]", relationFields="null") - extracting into managed persistable object
07/05/2012 11:00:43 PM org.datanucleus.ObjectManagerImpl putObjectIntoCache
FINE: Object "com.asteriski.mingle.venueportal.entity.MerchantPromotion@574a3347" (id="com.asteriski.mingle.venueportal.entity.MerchantPromotion:MerchantPromotion(5)") added to Level 1 cache (loadedFlags="[NNNYNNNNNN]")
07/05/2012 11:00:43 PM org.datanucleus.ObjectManagerImpl getObjectFromCache
FINE: Object with id="com.asteriski.mingle.venueportal.entity.MerchantPromotion:MerchantPromotion(5)" taken from Level 2 cache represented as "com.asteriski.mingle.venueportal.entity.MerchantPromotion@574a3347"
07/05/2012 11:00:43 PM org.datanucleus.state.LifeCycleState changeState
FINE: Object "com.asteriski.mingle.venueportal.entity.MerchantPromotion@574a3347" (id="com.asteriski.mingle.venueportal.entity.MerchantPromotion:MerchantPromotion(5)") has a lifecycle change : "P_CLEAN"->"P_NONTRANS"
07/05/2012 11:00:43 PM org.datanucleus.store.connection.ConnectionManagerImpl allocateConnection
FINE: Connection found in the pool : com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl$DatastoreManagedConnection@230cc23b for key=org.datanucleus.ObjectManagerImpl@2db1d931 in factory=ConnectionFactory:tx[com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl@7fac4f3e]
07/05/2012 11:00:43 PM com.asteriski.mingle.venueportal.service.PromotionService find
INFO: published:null
07/05/2012 11:00:43 PM org.datanucleus.store.connection.ConnectionManagerImpl$1 managedConnectionPostClose
FINE: Connection removed from the pool : com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl$DatastoreManagedConnection@230cc23b for key=org.datanucleus.ObjectManagerImpl@2db1d931 in factory=ConnectionFactory:tx[com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl@7fac4f3e]
07/05/2012 11:00:43 PM org.datanucleus.state.LifeCycleState changeState
FINE: Object "com.asteriski.mingle.venueportal.entity.MerchantPromotion@574a3347" (id="com.asteriski.mingle.venueportal.entity.MerchantPromotion:MerchantPromotion(5)") has a lifecycle change : "P_NONTRANS"->"DETACHED_CLEAN"
07/05/2012 11:00:43 PM org.datanucleus.ObjectManagerImpl removeObjectFromCache
FINE: Object with id="com.asteriski.mingle.venueportal.entity.MerchantPromotion:MerchantPromotion(5)" being removed from Level 1 cache [current cache size = 3]
07/05/2012 11:00:43 PM org.datanucleus.state.LifeCycleState changeState
FINE: Object "com.asteriski.mingle.venueportal.entity.MerchantPromotion@74f2794a" (id="com.asteriski.mingle.venueportal.entity.MerchantPromotion:MerchantPromotion(4)") has a lifecycle change : "P_NONTRANS"->"DETACHED_CLEAN"
07/05/2012 11:00:43 PM org.datanucleus.ObjectManagerImpl removeObjectFromCache
FINE: Object with id="com.asteriski.mingle.venueportal.entity.MerchantPromotion:MerchantPromotion(4)" being removed from Level 1 cache [current cache size = 2]
07/05/2012 11:00:43 PM org.datanucleus.state.LifeCycleState changeState
FINE: Object "com.asteriski.mingle.venueportal.entity.MerchantPromotion@1aa3c177" (id="com.asteriski.mingle.venueportal.entity.MerchantPromotion:MerchantPromotion(3)") has a lifecycle change : "P_NONTRANS"->"DETACHED_CLEAN"
07/05/2012 11:00:43 PM org.datanucleus.ObjectManagerImpl removeObjectFromCache
FINE: Object with id="com.asteriski.mingle.venueportal.entity.MerchantPromotion:MerchantPromotion(3)" being removed from Level 1 cache [current cache size = 1]
07/05/2012 11:00:43 PM org.datanucleus.ObjectManagerImpl disconnectSMCache
FINE: Level 1 Cache cleared
07/05/2012 11:00:43 PM org.datanucleus.ObjectManagerImpl initialiseLevel1Cache
FINE: Level 1 Cache of type "soft" initialised
答案 0 :(得分:0)
我在app引擎上使用jpa和datanucleus。如果我运行查询“DELETE FROM SOMETABLENAME a”,然后通过它的id获取对象,缓存仍然会返回它!
添加到我的persistance.xml文件修复了该问题。
当前的库版本
datanucleus-api-jdo-3.1.1
datanucleus-api-jpa-3.1.1
datanucleus-core-3.1.1
堆栈跟踪的一部分
ObjectManagerImpl.getObjectFromCache(Object) line: 5030
ObjectManagerImpl.findObject(Object, boolean, boolean, String) line: 3282
JPAEntityManager.find(Class<T>, Object, LockModeType, Map<String,Object>) line: 358
JPAEntityManager.find(Class, Object) line: 256
这是过去6个月内发生的更新吗?在更新到此版本之前,所有单元测试都没有问题。禁用缓存后,所有内容都会再次签出。 app引擎会尊重新设置吗?