当一个 hazelcast 在码头会话复制中出现故障时,我们得到 com.hazelcast.core.MemberLeftException

we get com.hazelcast.core.MemberLeftException when one hazelcast goes down in jetty session replication

我们使用 hazelcast 3.6.3 与 jetty 9.4 进行会话复制。 hazelcast 配置是

Config config = new Config();
    config.setInstanceName(HAZELCAST_INSTANCE_NAME);
    // logger config
    config.setProperty("hazelcast.logging.type", "slf4j");
    // config for session map
    MapConfig sessionMapConfig = new MapConfig();
    sessionMapConfig.setName(SESSION_MAP_NAME)
            .setBackupCount(2);
    config.addMapConfig(sessionMapConfig);
    // peer discovery with zookeeper
    config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
    config.setProperty(GroupProperty.DISCOVERY_SPI_ENABLED, "true");

    DiscoveryStrategyConfig discoveryStrategyConfig = new DiscoveryStrategyConfig(new ZookeeperDiscoveryStrategyFactory());
    discoveryStrategyConfig.addProperty(ZookeeperDiscoveryProperties.ZOOKEEPER_URL.key(), serviceDiscoveryNode);
    discoveryStrategyConfig.addProperty(ZookeeperDiscoveryProperties.ZOOKEEPER_PATH.key(), "sessionstore/APP");
    discoveryStrategyConfig.addProperty(ZookeeperDiscoveryProperties.GROUP.key(), "cluster-name");
    config.getNetworkConfig().getJoin().getDiscoveryConfig().addDiscoveryStrategyConfig(discoveryStrategyConfig);

当集群的其中一个成员出现故障时,我们会在日志中记录这一点

 2018-11-27 13:13:47,217 [WARN ] (1-thread-1) com.hazelcast.map.impl.query.MapQueryEngineImpl  - [10.x.x.x]:5702 [dev] [3.6.3] Could not get results
com.hazelcast.core.MemberLeftException: Member [10.x.x.x]:5701 has left cluster!
        at com.hazelcast.spi.impl.operationservice.impl.InvocationMonitor$OnMemberLeftTask.run(InvocationMonitor.java:284)
        at com.hazelcast.util.executor.CachedExecutorServiceDelegate$Worker.run(CachedExecutorServiceDelegate.java:212)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:748)
        at com.hazelcast.util.executor.HazelcastManagedThread.executeRun(HazelcastManagedThread.java:76)
        at com.hazelcast.util.executor.HazelcastManagedThread.run(HazelcastManagedThread.java:92)
        at ------ End remote and begin local stack-trace ------.(Unknown Source)
        at com.hazelcast.spi.impl.operationservice.impl.InvocationFuture.resolveApplicationResponse(InvocationFuture.java:387)
        at com.hazelcast.spi.impl.operationservice.impl.InvocationFuture.resolveApplicationResponseOrThrowException(InvocationFuture.java:337)
        at com.hazelcast.spi.impl.operationservice.impl.InvocationFuture.get(InvocationFuture.java:225)
        at com.hazelcast.spi.impl.operationservice.impl.InvocationFuture.get(InvocationFuture.java:204)
        at com.hazelcast.map.impl.query.MapQueryEngineImpl.addResultsOfPredicate(MapQueryEngineImpl.java:528)
        at com.hazelcast.map.impl.query.MapQueryEngineImpl.invokeQueryAllPartitions(MapQueryEngineImpl.java:421)
        at com.hazelcast.map.impl.proxy.MapProxyImpl.values(MapProxyImpl.java:637)
        at com.hazelcast.map.impl.proxy.MapProxyImpl.values(MapProxyImpl.java:625)
        at 

为什么在会话映射配置中启用分区备份时出现异常?

MemberLeftException 当成员在调用或执行期间离开集群时抛出,但它是 RetryableException,这意味着它将使用更新的成员列表重试。所以最终它应该自愈。

OTOH 我看到您使用的是 3.6.3,但最新的稳定版本是 3.11,考虑到此后有许多改进和修复,升级是个好主意。