瀏覽代碼

Internal: don't try to send a mapping refresh if there is no master

After processing mapping updates from the master, we compare the resulting binary representation of them and compare it the one cluster state has. If different, we send a refresh mapping request to master, asking it to reparse the mapping and serialize them again. This mechanism is used to update the mapping after a format change caused by a version upgrade.

The very same process can also be triggered when an old master leaves the cluster, triggering a local cluster state update. If that update contains old mapping format, the local node will again signal the need to refresh, but this time there is no master to accept the request. Instead of failing (which we now do because of #10283, we should just skip the notification and wait for the next elected master to publish a new mapping (triggering another refresh if needed).

Closes #10311
Boaz Leskes 10 年之前
父節點
當前提交
fd3b01d810
共有 1 個文件被更改,包括 8 次插入2 次删除
  1. 8 2
      src/main/java/org/elasticsearch/cluster/action/index/NodeMappingRefreshAction.java

+ 8 - 2
src/main/java/org/elasticsearch/cluster/action/index/NodeMappingRefreshAction.java

@@ -26,6 +26,7 @@ import org.elasticsearch.cluster.ClusterState;
 import org.elasticsearch.cluster.metadata.IndexMetaData;
 import org.elasticsearch.cluster.metadata.MetaDataMappingService;
 import org.elasticsearch.cluster.node.DiscoveryNodes;
+import org.elasticsearch.common.Strings;
 import org.elasticsearch.common.component.AbstractComponent;
 import org.elasticsearch.common.inject.Inject;
 import org.elasticsearch.common.io.stream.StreamInput;
@@ -55,11 +56,16 @@ public class NodeMappingRefreshAction extends AbstractComponent {
     }
 
     public void nodeMappingRefresh(final ClusterState state, final NodeMappingRefreshRequest request) throws ElasticsearchException {
-        DiscoveryNodes nodes = state.nodes();
+        final DiscoveryNodes nodes = state.nodes();
+        if (nodes.masterNode() == null) {
+            logger.warn("can't send mapping refresh for [{}][{}], no master known.", request.index(), Strings.arrayToCommaDelimitedString(request.types()));
+            return;
+        }
+
         if (nodes.localNodeMaster()) {
             innerMappingRefresh(request);
         } else {
-            transportService.sendRequest(state.nodes().masterNode(),
+            transportService.sendRequest(nodes.masterNode(),
                     ACTION_NAME, request, EmptyTransportResponseHandler.INSTANCE_SAME);
         }
     }