Java 使用ignite cluster时如何处理关键故障?

Java 使用ignite cluster时如何处理关键故障?,java,ignite,Java,Ignite,我想在生产环境2.6版中使用ignite群集。但我发现,当我运行以下代码时,会发生一些严重故障: CacheConfiguration<Long, User> cacheCfg = new CacheConfiguration<>("QQ"); cacheCfg.setIndexedTypes(Long.class, String.class); cacheCfg.setCacheMode(CacheMode.PARTITIONED); cacheCfg.setSqlSc

我想在生产环境2.6版中使用ignite群集。但我发现,当我运行以下代码时,会发生一些严重故障:

CacheConfiguration<Long, User> cacheCfg = new CacheConfiguration<>("QQ");
cacheCfg.setIndexedTypes(Long.class, String.class);
cacheCfg.setCacheMode(CacheMode.PARTITIONED);
cacheCfg.setSqlSchema("PUBLIC");
cacheCfg.setReadThrough(true);
IgniteCache<Long, User> cache = ignite.getOrCreateCache(cacheCfg);
集群中的所有节点都将崩溃。例外情况如下:

[22:00:12,240][SEVERE][exchange-worker-#43][CacheAffinitySharedManager] Failed to initialize cache. Will try to rollback cache start routine. [cacheName=QQ]
class org.apache.ignite.IgniteCheckedException: Cannot enable read-through (loader or store is not provided) for cache: QQ
    at org.apache.ignite.internal.processors.cache.GridCacheProcessor.validate(GridCacheProcessor.java:501)
    at org.apache.ignite.internal.processors.cache.GridCacheProcessor.createCache(GridCacheProcessor.java:1439)
    at org.apache.ignite.internal.processors.cache.GridCacheProcessor.prepareCacheStart(GridCacheProcessor.java:1945)
    at org.apache.ignite.internal.processors.cache.CacheAffinitySharedManager.onCacheChangeRequest(CacheAffinitySharedManager.java:791)
    at org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture.onCacheChangeRequest(GridDhtPartitionsExchangeFuture.java:987)
    at org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture.init(GridDhtPartitionsExchangeFuture.java:646)
    at org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$ExchangeWorker.body0(GridCachePartitionExchangeManager.java:2419)
    at org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$ExchangeWorker.body(GridCachePartitionExchangeManager.java:2299)
    at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
    at java.lang.Thread.run(Thread.java:748)
[22:00:12,258][SEVERE][exchange-worker-#43][GridDhtPartitionsExchangeFuture] Failed to reinitialize local partitions (preloading will be stopped): GridDhtPartitionExchangeId [topVer=AffinityTopologyVersion [topVer=6, minorTopVer=3], discoEvt=DiscoveryCustomEvent [customMsg=DynamicCacheChangeBatch [id=cb8ca50a761-71740993-a932-4d4f-8576-767a180422e4, reqs=[DynamicCacheChangeRequest [cacheName=QQ, hasCfg=true, nodeId=edcdfc7d-e80a-4e1c-8c95-df649ecf3f64, clientStartOnly=false, stop=false, destroy=false, disabledAfterStartfalse]], exchangeActions=ExchangeActions [startCaches=[QQ], stopCaches=null, startGrps=[QQ], stopGrps=[], resetParts=null, stateChangeRequest=null], startCaches=false], affTopVer=AffinityTopologyVersion [topVer=6, minorTopVer=3], super=DiscoveryEvent [evtNode=TcpDiscoveryNode [id=edcdfc7d-e80a-4e1c-8c95-df649ecf3f64, addrs=[0:0:0:0:0:0:0:1, 10.138.32.93, 10.202.235.150, 127.0.0.1, 192.168.117.1, 192.168.137.1, 192.168.56.1, 192.168.99.1, 2001:0:dcfa:40e1:18f9:17ae:f575:dfa2], sockAddrs=[/0:0:0:0:0:0:0:1:0, /127.0.0.1:0, /10.138.32.93:0, /2001:0:dcfa:40e1:18f9:17ae:f575:dfa2:0, /192.168.117.1:0, /192.168.137.1:0, /192.168.56.1:0, /192.168.99.1:0, /10.202.235.150:0], discPort=0, order=6, intOrder=5, lastExchangeTime=1544583579289, loc=false, ver=2.6.0#20180710-sha1:669feacc, isClient=true], topVer=6, nodeId8=0c16ea29, msg=null, type=DISCOVERY_CUSTOM_EVT, tstamp=1544583612234]], nodeId=edcdfc7d, evt=DISCOVERY_CUSTOM_EVT]
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.ArrayList.rangeCheck(ArrayList.java:657)
    at java.util.ArrayList.get(ArrayList.java:433)
    at org.apache.ignite.internal.processors.cache.CacheGroupContext.singleCacheContext(CacheGroupContext.java:385)
    at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition.<init>(GridDhtLocalPartition.java:198)
    at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionTopologyImpl.getOrCreatePartition(GridDhtPartitionTopologyImpl.java:812)
    at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionTopologyImpl.initPartitions(GridDhtPartitionTopologyImpl.java:368)
    at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionTopologyImpl.beforeExchange(GridDhtPartitionTopologyImpl.java:543)
    at org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture.distributedExchange(GridDhtPartitionsExchangeFuture.java:1141)
    at org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture.init(GridDhtPartitionsExchangeFuture.java:712)
    at org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$ExchangeWorker.body0(GridCachePartitionExchangeManager.java:2419)
    at org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$ExchangeWorker.body(GridCachePartitionExchangeManager.java:2299)
    at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
    at java.lang.Thread.run(Thread.java:748)
[22:00:12,263][SEVERE][exchange-worker-#43][GridCachePartitionExchangeManager] Failed to wait for completion of partition map exchange (preloading will not start): GridDhtPartitionsExchangeFuture [firstDiscoEvt=DiscoveryCustomEvent [customMsg=null, affTopVer=AffinityTopologyVersion [topVer=6, minorTopVer=3], super=DiscoveryEvent [evtNode=TcpDiscoveryNode [id=edcdfc7d-e80a-4e1c-8c95-df649ecf3f64, addrs=[0:0:0:0:0:0:0:1, 10.138.32.93, 10.202.235.150, 127.0.0.1, 192.168.117.1, 192.168.137.1, 192.168.56.1, 192.168.99.1, 2001:0:dcfa:40e1:18f9:17ae:f575:dfa2], sockAddrs=[/0:0:0:0:0:0:0:1:0, /127.0.0.1:0, /10.138.32.93:0, /2001:0:dcfa:40e1:18f9:17ae:f575:dfa2:0, /192.168.117.1:0, /192.168.137.1:0, /192.168.56.1:0, /192.168.99.1:0, /10.202.235.150:0], discPort=0, order=6, intOrder=5, lastExchangeTime=1544583579289, loc=false, ver=2.6.0#20180710-sha1:669feacc, isClient=true], topVer=6, nodeId8=0c16ea29, msg=null, type=DISCOVERY_CUSTOM_EVT, tstamp=1544583612234]], crd=TcpDiscoveryNode [id=0c16ea29-7560-43b5-960c-519ddf762374, addrs=[0:0:0:0:0:0:0:1%lo, 10.202.60.170, 127.0.0.1, 172.17.0.1], sockAddrs=[ignite-1.novalocal/10.202.60.170:10001, /0:0:0:0:0:0:0:1%lo:10001, /127.0.0.1:10001, /172.17.0.1:10001], discPort=10001, order=1, intOrder=1, lastExchangeTime=1544583612245, loc=true, ver=2.6.0#20180710-sha1:669feacc, isClient=false], exchId=GridDhtPartitionExchangeId [topVer=AffinityTopologyVersion [topVer=6, minorTopVer=3], discoEvt=DiscoveryCustomEvent [customMsg=null, affTopVer=AffinityTopologyVersion [topVer=6, minorTopVer=3], super=DiscoveryEvent [evtNode=TcpDiscoveryNode [id=edcdfc7d-e80a-4e1c-8c95-df649ecf3f64, addrs=[0:0:0:0:0:0:0:1, 10.138.32.93, 10.202.235.150, 127.0.0.1, 192.168.117.1, 192.168.137.1, 192.168.56.1, 192.168.99.1, 2001:0:dcfa:40e1:18f9:17ae:f575:dfa2], sockAddrs=[/0:0:0:0:0:0:0:1:0, /127.0.0.1:0, /10.138.32.93:0, /2001:0:dcfa:40e1:18f9:17ae:f575:dfa2:0, /192.168.117.1:0, /192.168.137.1:0, /192.168.56.1:0, /192.168.99.1:0, /10.202.235.150:0], discPort=0, order=6, intOrder=5, lastExchangeTime=1544583579289, loc=false, ver=2.6.0#20180710-sha1:669feacc, isClient=true], topVer=6, nodeId8=0c16ea29, msg=null, type=DISCOVERY_CUSTOM_EVT, tstamp=1544583612234]], nodeId=edcdfc7d, evt=DISCOVERY_CUSTOM_EVT], added=true, initFut=GridFutureAdapter [ignoreInterrupts=false, state=DONE, res=false, hash=533779784], init=false, lastVer=null, partReleaseFut=PartitionReleaseFuture [topVer=AffinityTopologyVersion [topVer=6, minorTopVer=3], futures=[ExplicitLockReleaseFuture [topVer=AffinityTopologyVersion [topVer=6, minorTopVer=3], futures=[]], AtomicUpdateReleaseFuture [topVer=AffinityTopologyVersion [topVer=6, minorTopVer=3], futures=[]], DataStreamerReleaseFuture [topVer=AffinityTopologyVersion [topVer=6, minorTopVer=3], futures=[]], LocalTxReleaseFuture [topVer=AffinityTopologyVersion [topVer=6, minorTopVer=3], futures=[]], AllTxReleaseFuture [topVer=AffinityTopologyVersion [topVer=6, minorTopVer=3], futures=[RemoteTxReleaseFuture [topVer=AffinityTopologyVersion [topVer=6, minorTopVer=3], futures=[]]]]]], exchActions=null, affChangeMsg=null, initTs=1544583612234, centralizedAff=false, forceAffReassignment=false, changeGlobalStateE=null, done=true, state=CRD, evtLatch=0, remaining=[8541a9eb-2c29-4e68-8c6c-0be8271d43b3, c4eb0a79-5ba4-4eba-80ea-6b0e1dc25853], super=GridFutureAdapter [ignoreInterrupts=false, state=DONE, res=java.lang.IndexOutOfBoundsException: Index: 0, Size: 0, hash=1173308534]]
class org.apache.ignite.IgniteCheckedException: Index: 0, Size: 0
    at org.apache.ignite.internal.util.IgniteUtils.cast(IgniteUtils.java:7307)
    at org.apache.ignite.internal.util.future.GridFutureAdapter.resolve(GridFutureAdapter.java:259)
    at org.apache.ignite.internal.util.future.GridFutureAdapter.get0(GridFutureAdapter.java:207)
    at org.apache.ignite.internal.util.future.GridFutureAdapter.get(GridFutureAdapter.java:159)
    at org.apache.ignite.internal.util.future.GridFutureAdapter.get(GridFutureAdapter.java:151)
    at org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$ExchangeWorker.body0(GridCachePartitionExchangeManager.java:2433)
    at org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$ExchangeWorker.body(GridCachePartitionExchangeManager.java:2299)
    at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.ArrayList.rangeCheck(ArrayList.java:657)
    at java.util.ArrayList.get(ArrayList.java:433)
    at org.apache.ignite.internal.processors.cache.CacheGroupContext.singleCacheContext(CacheGroupContext.java:385)
    at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition.<init>(GridDhtLocalPartition.java:198)
    at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionTopologyImpl.getOrCreatePartition(GridDhtPartitionTopologyImpl.java:812)
    at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionTopologyImpl.initPartitions(GridDhtPartitionTopologyImpl.java:368)
    at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionTopologyImpl.beforeExchange(GridDhtPartitionTopologyImpl.java:543)
    at org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture.distributedExchange(GridDhtPartitionsExchangeFuture.java:1141)
    at org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture.init(GridDhtPartitionsExchangeFuture.java:712)
    at org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$ExchangeWorker.body0(GridCachePartitionExchangeManager.java:2419)
    ... 3 more
[22:00:22] Topology snapshot [ver=7, servers=3, clients=0, CPUs=24, offheap=9.3GB, heap=3.0GB]
[22:00:22]   ^-- Node [id=0C16EA29-7560-43B5-960C-519DDF762374, clusterState=ACTIVE]
[22:00:22] Data Regions Configured:
[22:00:22]   ^-- default [initSize=256.0 MiB, maxSize=3.1 GiB, persistenceEnabled=false]
[22:00:22,359][SEVERE][exchange-worker-#43][] Critical system error detected. Will be handled accordingly to configured handler [hnd=class o.a.i.failure.StopNodeOrHaltFailureHandler, failureCtx=FailureContext [type=SYSTEM_WORKER_TERMINATION, err=java.lang.IndexOutOfBoundsException: Index: 0, Size: 0]]
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.ArrayList.rangeCheck(ArrayList.java:657)
    at java.util.ArrayList.get(ArrayList.java:433)
    at org.apache.ignite.internal.processors.cache.CacheGroupContext.singleCacheContext(CacheGroupContext.java:385)
    at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition.<init>(GridDhtLocalPartition.java:198)
    at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionTopologyImpl.getOrCreatePartition(GridDhtPartitionTopologyImpl.java:812)
    at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionTopologyImpl.rebalancePartition(GridDhtPartitionTopologyImpl.java:2178)
    at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionTopologyImpl.afterExchange(GridDhtPartitionTopologyImpl.java:698)
    at org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$ExchangeWorker.body0(GridCachePartitionExchangeManager.java:2488)
    at org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$ExchangeWorker.body(GridCachePartitionExchangeManager.java:2299)
    at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
    at java.lang.Thread.run(Thread.java:748)
[22:00:22,360][SEVERE][exchange-worker-#43][] JVM will be halted immediately due to the failure: [failureCtx=FailureContext [type=SYSTEM_WORKER_TERMINATION, err=java.lang.IndexOutOfBoundsException: Index: 0, Size: 0]]
之后群集中的所有节点都被压碎,所有缓存和数据都丢失。我尝试了中列出的其他故障处理程序,发现RestartProcessFailureHandler也会导致数据丢失,而NoOpFailureHandler会导致节点不接受后续请求


那么,在生产环境中使用ignite cluster时,如何处理关键故障呢

您的Ignite缓存创建配置错误。正确检查缓存配置。请参阅此链接

如果只需要将数据存储在缓存中,可以使用以下配置

CacheConfiguration<Long, User> cacheCfg = new CacheConfiguration<>("QQ");
cacheCfg.setCacheMode(CacheMode.PARTITIONED);
IgniteCache<Long, User> cache = ignite.getOrCreateCache(cacheCfg);

其中CacheStore是用户定义类,具有第三方数据操作指令

我想您可以通过扩展AbstractFailureHandler来编写自己的处理程序。是的,这可能是一个解决方案。我知道配置是配置,但我想说的是如何处理此错误。因为我想在生产环境中使用ignite,如果有人编写这样的代码,集群将崩溃,其他人将丢失他们的数据。很难确定所有人都会做正确的事情。这是你在问题中给出的完整配置吗?如果是,则此配置即使在本地环境中也不应工作。因为无论何时将setReadThrough或setWriteThrough属性设置为true,都需要添加其CacheStoreFactory。
cacheCfg.setReadThrough(true);
cacheCfg.setCacheStoreFactory(FactoryBuilder.factoryOf(CacheStore.class));