Skip to content

Commit fd3b01d

Browse files
committed
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
1 parent bd79f40 commit fd3b01d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/main/java/org/elasticsearch/cluster/action/index/NodeMappingRefreshAction.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.elasticsearch.cluster.metadata.IndexMetaData;
2727
import org.elasticsearch.cluster.metadata.MetaDataMappingService;
2828
import org.elasticsearch.cluster.node.DiscoveryNodes;
29+
import org.elasticsearch.common.Strings;
2930
import org.elasticsearch.common.component.AbstractComponent;
3031
import org.elasticsearch.common.inject.Inject;
3132
import org.elasticsearch.common.io.stream.StreamInput;
@@ -55,11 +56,16 @@ public NodeMappingRefreshAction(Settings settings, TransportService transportSer
5556
}
5657

5758
public void nodeMappingRefresh(final ClusterState state, final NodeMappingRefreshRequest request) throws ElasticsearchException {
58-
DiscoveryNodes nodes = state.nodes();
59+
final DiscoveryNodes nodes = state.nodes();
60+
if (nodes.masterNode() == null) {
61+
logger.warn("can't send mapping refresh for [{}][{}], no master known.", request.index(), Strings.arrayToCommaDelimitedString(request.types()));
62+
return;
63+
}
64+
5965
if (nodes.localNodeMaster()) {
6066
innerMappingRefresh(request);
6167
} else {
62-
transportService.sendRequest(state.nodes().masterNode(),
68+
transportService.sendRequest(nodes.masterNode(),
6369
ACTION_NAME, request, EmptyTransportResponseHandler.INSTANCE_SAME);
6470
}
6571
}

0 commit comments

Comments
 (0)