apache ignite系列(八):问题汇总
1,java.lang.ClassNotFoundException Unknown pair
1.Please try to turn on isStoreKeepBinary in cache settings - like this; please note the last line:
down vote
accepted
Please try to turn on isStoreKeepBinary in cache settings - like this; please note the last line:
if (persistence){
// Configuring Cassandra's persistence
DataSource dataSource = new DataSource();
// ...here go the rest of your settings as they appear now...
configuration.setWriteBehindEnabled(true);
configuration.setStoreKeepBinary(true);
}
This setting forces Ignite to avoid binary deserialization when working with underlying cache store.
2.I can reproduce it when, in loadCaches(), I put something that isn't exactly the expected Item in the cache:
private void loadCache(IgniteCache<Integer, Item> cache, /* Ignite.binary() */ IgniteBinary binary) {
// Note the absence of package name here:
BinaryObjectBuilder builder = binary.builder("Item");
builder.setField("name", "a");
builder.setField("brand", "B");
builder.setField("type", "c");
builder.setField("manufacturer", "D");
builder.setField("description", "e");
builder.setField("itemId", 1);
参考链接:
http://apache-ignite-users.70518.x6.nabble.com/ClassNotFoundException-with-affinity-run-td5359.html
https://stackoverflow.com/questions/47502111/apache-ignite-ignitecheckedexception-unknown-pair#
2,java.lang.IndexOutOfBoundsException + Failed to wait for completion of partition map exchange
异常描述:
2018-06-06 14:24:02.932 ERROR 17364 --- [ange-worker-#42] .c.d.d.p.GridDhtPartitionsExchangeFuture : Failed to reinitialize local partitions (preloading will be stopped):
...
java.lang.IndexOutOfBoundsException: index 678
... org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$ExchangeWorker.body(GridCachePartitionExchangeManager.java:2279) [ignite-core-2.3.0.jar:2.3.0]
at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110) [ignite-core-2.3.0.jar:2.3.0]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_73]
2018-06-06 14:24:02.932 INFO 17364 --- [ange-worker-#42] .c.d.d.p.GridDhtPartitionsExchangeFuture : Finish exchange future [startVer=AffinityTopologyVersion [topVer=1, minorTopVer=1], resVer=null, err=java.lang.IndexOutOfBoundsException: index 678]
2018-06-06 14:24:02.941 ERROR 17364 --- [ange-worker-#42] .i.p.c.GridCachePartitionExchangeManager : Failed to wait for completion of partition map exchange (preloading will not start): GridDhtPartitionsExchangeFuture
...
org.apache.ignite.IgniteCheckedException: index 678
at org.apache.ignite.internal.util.IgniteUtils.cast(IgniteUtils.java:7252) ~[ignite-core-2.3.0.jar:2.3.0]
....
org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$ExchangeWorker.body(GridCachePartitionExchangeManager.java:2279) ~[ignite-core-2.3.0.jar:2.3.0]
... 2 common frames omitted
出现这个情况的原因如下:
如果定义的缓存类型是REPLICATED模式,并且开启了持久化,后面将其改为PARTITIONED模式,并导入数据,后续重启的时候就会报这个错误。
比如下面这种情况:
default-config.xml
<property name="cacheConfiguration">
<list>
<bean class="org.apache.ignite.configuration.CacheConfiguration">
...
<property name="name" value="Test"/>
<property name="atomicityMode" value="ATOMIC"/>
<property name="cacheMode" value="REPLICATED"/>
...
</bean>
</list>
</property>
ignite.destroyCache("Test");
IgniteCache<Long, CommRate> cache = ignite.getOrCreateCache("Test");
当重新启动的时候,default-config.xml中的配置先生效,所以会出现这个问题。
解决办法就是在持久化模式下不要更改缓存模式,或者不要在配置文件中预定义缓存类型。
I can't reproduce your case. But the issue could occur if you had a REPLICATED cache and after some time changed it to PARTITIONED and for example call to getOrCreateCache keeping old cache name.
参考链接:
http://apache-ignite-users.70518.x6.nabble.com/Weird-index-out-bound-Exception-td14905.html
3,Failed to find SQL table for type xxxx
导入数据有误,将该cache destroy掉重新导入.
4, ignite消息机制出现重复消息并且按执行次数递增
ignite消息机制出现重复消息并且按执行次数递增的原因是添加了多次监听器。
针对相同主题的remoteListen和localListen都只应该执行一次,不然每重复执行一次就会多增加一个监听器,
然后表现出的现象就像是消息按执行次数重复发。
private AtomicBoolean rmtMsgInit = new AtomicBoolean(false);
private AtomicBoolean localMsgInit = new AtomicBoolean(false);
@RequestMapping("/msgTest")
public @ResponseBody
String orderedMsg(HttpServletRequest request, HttpServletResponse response) {
/***************************remote message****************************/
IgniteMessaging rmtMsg = ignite.message(ignite.cluster().forRemotes());
/**相同的消息监听只能设置一次,不然会出现接收到重复消息,并且按次数递增*/
if(!rmtMsgInit.get()) {
rmtMsg.remoteListen("MyOrderdTopic", (nodeId, msg) -> {
System.out.println("Received ordered message [msg=" + msg +", from=" + nodeId + "]");
return true;
});
rmtMsgInit.set(true);
}
rmtMsg.send("MyOrderdTopic", UUID.randomUUID().toString());
// for (int i=0; i < 10; i++) {
// rmtMsg.sendOrdered("MyOrderdTopic", Integer.toString(i), 0);
// rmtMsg.send("MyOrderdTopic", Integer.toString(i));
// }
/***************************local message****************************/
IgniteMessaging localMsg = ignite.message(ignite.cluster().forLocal());
/**相同的消息监听只能设置一次,不然会出现接收到重复消息,并且按次数递增*/
if(!localMsgInit.get()){
localMsg.localListen("localTopic", (nodeId, msg) -> {
System.out.println(String.format("Received local message [msg=%s, from=%s]", msg, nodeId));
return true;
});
localMsgInit.set(true);
}
localMsg.send("localTopic", UUID.randomUUID().toString());
return "executed!";
}
5,ignite远程执行(remote)之类的操作控制台无打印
一般在ignite.cluster().forRemotes()远程执行相关的操作的时候,程序可能会在其他节点执行,
所以打印的日志和输出也会在节点上输出,而程序终端不一定会有输出。
例如:
IgniteMessaging rmtMsg = ignite.message(ignite.cluster().forRemotes());
rmtMsg.remoteListen("MyOrderdTopic", (nodeId, msg) -> {
System.out.println("Received ordered message [msg=" + msg +", from=" + nodeId + "]");
return true;
});
如果想在程序端看到效果,可以使用本地模式:
IgniteMessaging.localListen
ignite.events().localListen
6,ignite持久化占用磁盘空间过大
wal日志机制
增加如下配置,修改wal日志同步频率
<!-- Redefining maximum memory size for the cluster node usage. -->
<property name="dataStorageConfiguration">
<bean class="org.apache.ignite.configuration.DataStorageConfiguration">
...
<!--Checkpointing frequency which is a minimal interval when the dirty pages will be written to the Persistent Store.-->
<property name="checkpointFrequency" value="180000"/>
<!-- Number of threads for checkpointing.-->
<property name="checkpointThreads" value="4"/>
<!-- Number of checkpoints to be kept in WAL after checkpoint is finished.-->
<property name="walHistorySize" value="20"/>
...
</bean>
</property>