2

appengine 1.6.4 datanucleus-appengine-2.0.0 datanucleus 缓存 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
4

1 回答 1

0

我在应用引擎上使用 jpa 和 datanucleus。如果我运行查询“DELETE FROM SOMETABLENAME a”,然后通过它的 id 获取对象,缓存仍然会返回它!

添加到我的 persistence.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 个月内发生的更新吗?在更新到此版本之前,所有单元测试都很好。禁用缓存后,一切都会再次签出。应用引擎会尊重新设置吗?

于 2012-12-05T12:43:39.027 回答