代码之家  ›  专栏  ›  技术社区  ›  MondKin

ElasticSearch的MasterService计算群集状态花费的时间太长

  •  0
  • MondKin  · 技术社区  · 4 年前

    [WARN ][o.e.c.s.MasterService    ] [NODE_NAME_1] took [28.3s], which is over [10s], to compute cluster state update for [put-mapping[_doc, _doc, ...
    [DEBUG][o.e.a.a.i.m.p.TransportPutMappingAction] [NODE_NAME_1] failed to put mappings on indices [[[INDEX_1/SOME_ID]]], type [_doc]
    org.elasticsearch.cluster.metadata.ProcessClusterEventTimeoutException: failed to process cluster event (put-mapping) within 30s
        at org.elasticsearch.cluster.service.MasterService$Batcher.lambda$onTimeout$0(MasterService.java:143) [elasticsearch-7.5.2.jar:7.5.2]
        at java.util.ArrayList.forEach(ArrayList.java:1507) [?:?]
        at org.elasticsearch.cluster.service.MasterService$Batcher.lambda$onTimeout$1(MasterService.java:142) [elasticsearch-7.5.2.jar:7.5.2]
        at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:703) [elasticsearch-7.5.2.jar:7.5.2]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
        at java.lang.Thread.run(Thread.java:830) [?:?]
    

    在第一行,我把省略号放在末尾,因为它实际上很大,这里是我们看到的图像(这行突然结束,正如你在图像中看到的):

    enter image description here

    你知道那些错误信息是关于什么的吗?

    谢谢。

    • 我们使用ElasticSearch 7.5.2
    • 我们不使用ILM,当我说“滚动我们的索引”时,我们要做的是开始写入我们几个小时前创建但没有使用的新索引。然后我们就停止写旧的索引了。
    0 回复  |  直到 4 年前
        1
  •  3
  •   Amit    4 年前

    MasterService.java

    您没有大量的碎片信息,这些信息是在集群状态下维护的,您的主节点无法在默认情况下计算状态 10s .

    下面是Elasticsearch类的代码 org.elasticsearch.cluster.service.ClusterApplierService ,它尝试更新群集状态并引发此异常。

    try {
        UpdateTask updateTask = new UpdateTask(config.priority(), source, new SafeClusterApplyListener(listener, logger), executor);
        if (config.timeout() != null) {
            threadPoolExecutor.execute(updateTask, config.timeout(),
                () -> threadPool.generic().execute(
                    () -> listener.onFailure(source, new ProcessClusterEventTimeoutException(config.timeout(), source))));
        } else {
            threadPoolExecutor.execute(updateTask);
        }
    }
    

    org.elasticsearch.cluster.metadata.ProcessClusterEventTimeoutException 代码如下

    public ProcessClusterEventTimeoutException(TimeValue timeValue, String source) {
            super("failed to process cluster event (" + source + ") within " + timeValue);
        }
    

    一些解决问题的建议:

    1. 删除不必要的索引,这将减少碎片和集群状态的数量。
    2. 下面是发布集群状态的设置,这是第二步,如果您看到发布需要很长时间,那么如果您确定您的一些数据节点在此期间不可用,您可以这样做。
    cluster.publish.info_timeout = 10s default(maybe this can work)
    cluster.publish.timeout = 30s by default
    

    编辑:-基于在OP的评论中,由于他可以选择减少碎片的数量,他补充道 opster's guide on the optimal number of shards and replicas .