diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportResumeFollowAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportResumeFollowAction.java index 3583167fbb0..7e761e00bd9 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportResumeFollowAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportResumeFollowAction.java @@ -15,8 +15,10 @@ import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.block.ClusterBlockException; import org.elasticsearch.cluster.block.ClusterBlockLevel; import org.elasticsearch.cluster.metadata.IndexMetaData; +import org.elasticsearch.cluster.routing.UnassignedInfo; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider; +import org.elasticsearch.cluster.routing.allocation.decider.MaxRetryAllocationDecider; import org.elasticsearch.cluster.routing.allocation.decider.ShardsLimitAllocationDecider; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; @@ -28,8 +30,11 @@ import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.IndexingSlowLog; +import org.elasticsearch.index.MergePolicyConfig; +import org.elasticsearch.index.MergeSchedulerConfig; import org.elasticsearch.index.SearchSlowLog; import org.elasticsearch.index.cache.bitset.BitsetFilterCache; +import org.elasticsearch.index.engine.EngineConfig; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.indices.IndicesRequestCache; @@ -335,21 +340,37 @@ public class TransportResumeFollowAction extends TransportMasterNodeAction> WHITE_LISTED_SETTINGS; + /** + * These are settings that are not replicated to the follower index and + * therefor these settings are not validated whether they have the same + * value between leader and follower index. + * + * These dynamic settings don't affect how documents are indexed (affect index time text analysis) and / or + * are inconvenient if they were replicated (e.g. changing number of replicas). + */ + static final Set> WHITE_LISTED_SETTINGS; static { final Set> whiteListedSettings = new HashSet<>(); whiteListedSettings.add(IndexMetaData.INDEX_NUMBER_OF_REPLICAS_SETTING); whiteListedSettings.add(IndexMetaData.INDEX_AUTO_EXPAND_REPLICAS_SETTING); - whiteListedSettings.add(IndexMetaData.INDEX_ROUTING_EXCLUDE_GROUP_SETTING); whiteListedSettings.add(IndexMetaData.INDEX_ROUTING_INCLUDE_GROUP_SETTING); whiteListedSettings.add(IndexMetaData.INDEX_ROUTING_REQUIRE_GROUP_SETTING); + whiteListedSettings.add(IndexMetaData.INDEX_READ_ONLY_SETTING); + whiteListedSettings.add(IndexMetaData.INDEX_BLOCKS_READ_SETTING); + whiteListedSettings.add(IndexMetaData.INDEX_BLOCKS_WRITE_SETTING); + whiteListedSettings.add(IndexMetaData.INDEX_BLOCKS_METADATA_SETTING); + whiteListedSettings.add(IndexMetaData.INDEX_BLOCKS_READ_ONLY_ALLOW_DELETE_SETTING); + whiteListedSettings.add(IndexMetaData.INDEX_PRIORITY_SETTING); + whiteListedSettings.add(IndexMetaData.SETTING_WAIT_FOR_ACTIVE_SHARDS); + whiteListedSettings.add(EnableAllocationDecider.INDEX_ROUTING_REBALANCE_ENABLE_SETTING); whiteListedSettings.add(EnableAllocationDecider.INDEX_ROUTING_ALLOCATION_ENABLE_SETTING); whiteListedSettings.add(ShardsLimitAllocationDecider.INDEX_TOTAL_SHARDS_PER_NODE_SETTING); + whiteListedSettings.add(MaxRetryAllocationDecider.SETTING_ALLOCATION_MAX_RETRY); + whiteListedSettings.add(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING); - whiteListedSettings.add(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING); whiteListedSettings.add(IndexSettings.MAX_RESULT_WINDOW_SETTING); whiteListedSettings.add(IndexSettings.INDEX_WARMER_ENABLED_SETTING); whiteListedSettings.add(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING); @@ -361,6 +382,26 @@ public class TransportResumeFollowAction extends TransportMasterNodeAction> replicatedSettings = new HashSet<>(); + + // These fields need to be replicated otherwise documents that can be indexed in the leader index cannot + // be indexed in the follower index: + replicatedSettings.add(MapperService.INDEX_MAPPING_TOTAL_FIELDS_LIMIT_SETTING); + replicatedSettings.add(MapperService.INDEX_MAPPING_NESTED_DOCS_LIMIT_SETTING); + replicatedSettings.add(MapperService.INDEX_MAPPING_NESTED_FIELDS_LIMIT_SETTING); + replicatedSettings.add(MapperService.INDEX_MAPPING_DEPTH_LIMIT_SETTING); + replicatedSettings.add(MapperService.INDEX_MAPPER_DYNAMIC_SETTING); + replicatedSettings.add(IndexSettings.MAX_NGRAM_DIFF_SETTING); + replicatedSettings.add(IndexSettings.MAX_SHINGLE_DIFF_SETTING); + replicatedSettings.add(EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS); + + for (Setting setting : IndexScopedSettings.BUILT_IN_INDEX_SETTINGS) { + if (setting.isDynamic()) { + boolean notReplicated = TransportResumeFollowAction.WHITE_LISTED_SETTINGS.contains(setting); + boolean replicated = replicatedSettings.contains(setting); + assertThat("setting [" + setting.getKey() + "] is not classified as replicated xor not replicated", + notReplicated ^ replicated, is(true)); + } + } + } private static IndexMetaData createIMD(String index, int numberOfShards,