Entries not deleted from Database with JPA Cache Store
rajivpatil Feb 13, 2018 8:36 AMI created a very simple set-up, I have one table, one simple JPA Entity (no associations) . When i delete the entity from Infinispan Cache, the entry only gets deleted from the cache and not from datastore, it seems from the logs that underlying CacheStore is not even invoked.
Retrieve / Insert / Update - are working fine, only delete is having problem, pls help
persistence.xml
<persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="TEST_UNIT" transaction-type="RESOURCE_LOCAL">
<class>com.xxx.ts.test.entity.Group</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver" />
<property name="javax.persistence.jdbc.url" value="jdbc:derby://localhost:1527/rulesdb" />
<property name="javax.persistence.jdbc.user" value="" />
<property name="javax.persistence.jdbc.password" value="" />
<property name="javax.persistence.schema-generation.database.action" value="none"/>
</properties>
</persistence-unit>
</persistence>
Cache Manager
this.cacheMgr = new DefaultCacheManager(
GlobalConfigurationBuilder.defaultClusteredBuilder()
.transport().nodeName(System.getProperty("NodeName"))
.build());
Configuration ruleGrpCacheConfig = new ConfigurationBuilder().clustering()
.cacheMode(CacheMode.REPL_SYNC)
.persistence().passivation(false)
.addStore(JpaStoreConfigurationBuilder.class).purgeOnStartup(false).shared(true)
.persistenceUnitName("TEST_UNIT")
.entityClass(Group.class)
.storeMetadata(false)
.preload(true)
.build();
this.cacheMgr.defineConfiguration("TEST_UNIT", ruleGrpCacheConfig);
Group Entity
@Entity
@Table(name="GROUP_DEFINITION")
public class Group {
@Id
@Column(name="ID")
protected long Id;
@Column(name="XXX")
protected String xxxx;
@Column(name="YYYY")
protected String yyyy;
@Column(name="zzzz")
protected String zzzz;
.. setters / getters
Logs
18:23:29,207 TRACE [org.infinispan.interceptors.impl.InvocationContextInterceptor] - Invoked with command RemoveCommand{key=10, value=null, metadata=null, flags=[], commandInvocationId=CommandInvocation:N2-65108:4, valueMatcher=MATCH_ALWAYS, topologyId=-1} and InvocationContext [SingleKeyNonTxInvocationContext{isLocked=false, key=null, cacheEntry=null, origin=null, lockOwner=CommandInvocation:N2-65108:4}]
18:23:29,207 TRACE [org.infinispan.statetransfer.StateTransferInterceptor] - handleNonTxWriteCommand for command RemoveCommand{key=10, value=null, metadata=null, flags=[], commandInvocationId=CommandInvocation:N2-65108:4, valueMatcher=MATCH_ALWAYS, topologyId=-1}, topology id -1
18:23:29,207 TRACE [org.infinispan.statetransfer.StateTransferInterceptor] - Setting command topology to 1
18:23:29,207 TRACE [org.infinispan.interceptors.locking.NonTransactionalLockingInterceptor] - Are (N2-65108) we the lock owners for key '10'? true
18:23:29,207 TRACE [org.infinispan.util.concurrent.locks.impl.DefaultLockManager] - Lock key=10 for owner=CommandInvocation:N2-65108:4. timeout=10000 (MILLISECONDS)
18:23:29,212 TRACE [org.infinispan.util.concurrent.locks.impl.InfinispanLock] - Acquire lock for CommandInvocation:N2-65108:4. Timeout=10000 (MILLISECONDS)
18:23:29,212 TRACE [org.infinispan.util.concurrent.locks.impl.InfinispanLock] - Created a new one: LockPlaceHolder{lockState=WAITING, owner=CommandInvocation:N2-65108:4}
18:23:29,212 TRACE [org.infinispan.util.concurrent.locks.impl.InfinispanLock] - Try acquire. Next in queue=LockPlaceHolder{lockState=WAITING, owner=CommandInvocation:N2-65108:4}. Current=null
18:23:29,212 TRACE [org.infinispan.util.concurrent.locks.impl.InfinispanLock] - Lock Owner CAS(null, LockPlaceHolder{lockState=WAITING, owner=CommandInvocation:N2-65108:4}) => true
18:23:29,212 TRACE [org.infinispan.util.concurrent.locks.impl.InfinispanLock] - State changed for LockPlaceHolder{lockState=ACQUIRED, owner=CommandInvocation:N2-65108:4}. WAITING => ACQUIRED
18:23:29,212 TRACE [org.infinispan.util.concurrent.locks.impl.InfinispanLock] - LockPlaceHolder{lockState=ACQUIRED, owner=CommandInvocation:N2-65108:4} successfully acquired the lock.
18:23:29,213 TRACE [org.infinispan.container.EntryFactoryImpl] - Exists in context? null
18:23:29,214 TRACE [org.infinispan.container.EntryFactoryImpl] - Retrieved from container ImmortalCacheEntry{key=10, value=com.xxx.ts.test.entity.Group@a033ccf5}
18:23:29,214 TRACE [org.infinispan.container.EntryFactoryImpl] - Creating new entry for key 10
18:23:29,214 TRACE [org.infinispan.container.EntryFactoryImpl] - Updated context entry null -> ReadCommittedEntry(721c12){key=10, value=com.xxx.ts.test.entity.Group@a033ccf5, isCreated=false, isChanged=false, isRemoved=false, isExpired=false, skipLookup=false, metadata=EmbeddedMetadata{version=null}}
18:23:29,214 TRACE [org.infinispan.interceptors.impl.CacheLoaderInterceptor] - Skip load for command RemoveCommand{key=10, value=null, metadata=null, flags=[], commandInvocationId=CommandInvocation:N2-65108:4, valueMatcher=MATCH_ALWAYS, topologyId=1}. Entry ReadCommittedEntry(721c12){key=10, value=com.xxx.ts.test.entity.Group@a033ccf5, isCreated=false, isChanged=false, isRemoved=false, isExpired=false, skipLookup=false, metadata=EmbeddedMetadata{version=null}} (skipLookup=false) has non-null value.
18:23:29,223 TRACE [org.infinispan.interceptors.distribution.BaseDistributionInterceptor] - Current topology 1, command topology 1
18:23:29,223 TRACE [org.infinispan.interceptors.impl.CallInterceptor] - Invoking: RemoveCommand
18:23:29,223 TRACE [org.infinispan.interceptors.distribution.BaseDistributionInterceptor] - Current topology 1, command topology 1
18:23:29,225 TRACE [org.infinispan.interceptors.impl.DistCacheWriterInterceptor] - Removed entry under key 10 and got response false from CacheStore
18:23:29,225 TRACE [org.infinispan.interceptors.impl.EntryWrappingInterceptor] - About to commit entry ReadCommittedEntry(721c12){key=10, value=null, isCreated=false, isChanged=true, isRemoved=true, isExpired=false, skipLookup=false, metadata=EmbeddedMetadata{version=null}}
18:23:29,226 TRACE [org.infinispan.statetransfer.CommitManager] - Trying to commit. Key=10. Operation Flag=null, L1 write/invalidation=false
18:23:29,226 TRACE [org.infinispan.statetransfer.CommitManager] - Committing key=10. It is a L1 invalidation or a normal put and no tracking is enabled!
18:23:29,226 TRACE [org.infinispan.container.entries.ReadCommittedEntry] - Updating entry (key=10 removed=true changed=true created=false value=null metadata=EmbeddedMetadata{version=null})
18:23:29,227 TRACE [org.infinispan.container.DefaultDataContainer] - Removed ImmortalCacheEntry{key=10, value=com.xxx.ts.test.entity.Group@a033ccf5} from container
18:23:29,228 TRACE [org.infinispan.util.concurrent.locks.impl.DefaultLockManager] - Release locks for keys=[10]. owner=CommandInvocation:N2-65108:4
18:23:29,228 TRACE [org.infinispan.util.concurrent.locks.impl.InfinispanLock] - Release lock for CommandInvocation:N2-65108:4.
18:23:29,228 TRACE [org.infinispan.util.concurrent.locks.impl.InfinispanLock] - State changed for LockPlaceHolder{lockState=RELEASED, owner=CommandInvocation:N2-65108:4}. ACQUIRED => RELEASED
18:23:29,229 TRACE [org.infinispan.util.concurrent.locks.impl.InfinispanLock] - Release lock for LockPlaceHolder{lockState=RELEASED, owner=CommandInvocation:N2-65108:4}? true
18:23:29,229 TRACE [org.infinispan.util.concurrent.locks.impl.InfinispanLock] - Try acquire. Next in queue=null. Current=LockPlaceHolder{lockState=RELEASED, owner=CommandInvocation:N2-65108:4}
18:23:29,229 TRACE [org.infinispan.util.concurrent.locks.impl.InfinispanLock] - Lock Owner CAS(LockPlaceHolder{lockState=RELEASED, owner=CommandInvocation:N2-65108:4}, null) => true
18:23:29,229 TRACE [org.infinispan.util.concurrent.locks.impl.InfinispanLock] - Try acquire. Next in queue=null. Current=null