我有一个应用程序在2个群集内的4个节点上运行。该应用程序已使用infinispan和SpringEmbeddedCacheManager配置了缓存。尝试将数据添加到缓存时遇到间歇性问题,请注意,我正在将数据添加为键值对,其中我的值将始终是自定义类。
我只是试图将缓存类型更改为复制,本地和无效,我发现使用本地或无效缓存时没有问题。任何人都可以确认分布式缓存中的大对象是否引起任何问题。
Infinispan配置
<distributed-cache name="apigw-access-cache" owners="1" segments="20" mode="SYNC" statistics="false">
<eviction max-entries="10" strategy="LIRS"/>
<expiration max-idle="360000" lifespan="3600000"/>
</distributed-cache>
Infinispan版本
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-spring4</artifactId>
<version>7.0.3.Final</version><!--$NO-MVN-MAN-VER$ -->
</dependency>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-cli-server</artifactId>
<version>7.0.0.CR1</version>
</dependency>
错误
2019-12-04 09:44:23.361 [qtp1933072581-15447] ERROR o.i.i.InvocationContextInterceptor - ISPN000136: Execution error
org.infinispan.remoting.RemoteException: ISPN000217: Received exception from node-10097-32028, see cause for remote stack trace
at org.infinispan.remoting.transport.AbstractTransport.checkResponse(AbstractTransport.java:44) ~[infinispan-core-7.0.3.Final.jar!/:7.0.3.Final]
at org.infinispan.remoting.transport.jgroups.CommandAwareRpcDispatcher.processSingleCall(CommandAwareRpcDispatcher.java:381) ~[infinispan-core-7.0.3.Final.jar!/:7.0.3.Final]
at org.infinispan.remoting.transport.jgroups.CommandAwareRpcDispatcher.invokeRemoteCommand(CommandAwareRpcDispatcher.java:167) ~[infinispan-core-7.0.3.Final.jar!/:7.0.3.Final]
at org.infinispan.remoting.transport.jgroups.JGroupsTransport.invokeRemotely(JGroupsTransport.java:560) ~[infinispan-core-7.0.3.Final.jar!/:7.0.3.Final]
at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:290) ~[infinispan-core-7.0.3.Final.jar!/:7.0.3.Final]
Caused by: java.lang.IllegalArgumentException: Can not set java.util.Set field Class.field to java.lang.String
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167) ~[na:1.8.0_121]
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171) ~[na:1.8.0_121]
at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81) ~[na:1.8.0_121]
at java.lang.reflect.Field.set(Field.java:764) ~[na:1.8.0_121]
Caused by: org.infinispan.commons.CacheException: Problems invoking command.
at org.infinispan.remoting.transport.jgroups.CommandAwareRpcDispatcher.handle(CommandAwareRpcDispatcher.java:221)
at org.jgroups.blocks.RequestCorrelator.handleRequest(RequestCorrelator.java:460)
at org.jgroups.blocks.RequestCorrelator.receiveMessage(RequestCorrelator.java:377)
Caused by: org.infinispan.commons.CacheException: Problems invoking command.
at org.infinispan.remoting.transport.jgroups.CommandAwareRpcDispatcher.handle(CommandAwareRpcDispatcher.java:221) ~[infinispan-core-7.0.3.Final.jar!/:7.0.3.Final]
at org.jgroups.blocks.RequestCorrelator.handleRequest(RequestCorrelator.java:460) ~[jgroups-3.6.1.Final.jar!/:3.6.1.Final]
at org.jgroups.blocks.RequestCorrelator.receiveMessage(RequestCorrelator.java:377) ~[jgroups-3.6.1.Final.jar!/:3.6.1.Final]
首先,您不应该使用Infinispan的旧版本,应该升级到9.4.17.Final。>
[堆栈跟踪片段似乎没有正确的顺序,但是Can not set java.util.Set field Class.field to java.lang.String
是因为您的两个节点具有相同类的不同版本。
分布式缓存和失效缓存之间的最大区别是,分布式缓存将值复制到其他节点,而失效缓存则发送仅包含密钥的失效消息。如果失效缓存有效,则问题几乎可以肯定是您的一个值类已更改,并且其中一个节点仍具有旧版本。