浏览代码

Skip Expensive InternalSnapshotInfoService Application in some Cases (#79618)

If nothing about the routing changed, no need to run this thing.
Armin Braun 4 年之前
父节点
当前提交
47ebdf2cb8
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      server/src/main/java/org/elasticsearch/snapshots/InternalSnapshotsInfoService.java

+ 6 - 0
server/src/main/java/org/elasticsearch/snapshots/InternalSnapshotsInfoService.java

@@ -127,6 +127,12 @@ public class InternalSnapshotsInfoService implements ClusterStateListener, Snaps
     @Override
     public void clusterChanged(ClusterChangedEvent event) {
         if (event.localNodeMaster()) {
+            if (event.previousState().nodes().isLocalNodeElectedMaster()
+                && event.routingTableChanged() == false
+                && event.nodesChanged() == false) {
+                // we neither just became master nor did the routing table change, nothing to update
+                return;
+            }
             final Set<SnapshotShard> onGoingSnapshotRecoveries = listOfSnapshotShards(event.state());
 
             int unknownShards = 0;