Skip to content

Commit 6bd3f4c

Browse files
martijnvgjasontedor
authored andcommitted
[CCR] Adjust list of dynamic index settings that should be replicated (#35195)
Adjust list of dynamic index settings that should be replicated and added a test that verifies whether builtin dynamic index settings are classified as replicated or non replicated (whitelisted).
1 parent e420b21 commit 6bd3f4c

File tree

2 files changed

+89
-4
lines changed

2 files changed

+89
-4
lines changed

x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportResumeFollowAction.java

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
import org.elasticsearch.cluster.block.ClusterBlockException;
1616
import org.elasticsearch.cluster.block.ClusterBlockLevel;
1717
import org.elasticsearch.cluster.metadata.IndexMetaData;
18+
import org.elasticsearch.cluster.routing.UnassignedInfo;
1819
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
1920
import org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider;
21+
import org.elasticsearch.cluster.routing.allocation.decider.MaxRetryAllocationDecider;
2022
import org.elasticsearch.cluster.routing.allocation.decider.ShardsLimitAllocationDecider;
2123
import org.elasticsearch.cluster.service.ClusterService;
2224
import org.elasticsearch.common.inject.Inject;
@@ -28,8 +30,11 @@
2830
import org.elasticsearch.index.IndexNotFoundException;
2931
import org.elasticsearch.index.IndexSettings;
3032
import org.elasticsearch.index.IndexingSlowLog;
33+
import org.elasticsearch.index.MergePolicyConfig;
34+
import org.elasticsearch.index.MergeSchedulerConfig;
3135
import org.elasticsearch.index.SearchSlowLog;
3236
import org.elasticsearch.index.cache.bitset.BitsetFilterCache;
37+
import org.elasticsearch.index.engine.EngineConfig;
3338
import org.elasticsearch.index.mapper.MapperService;
3439
import org.elasticsearch.index.shard.ShardId;
3540
import org.elasticsearch.indices.IndicesRequestCache;
@@ -334,21 +339,37 @@ static String[] extractLeaderShardHistoryUUIDs(Map<String, String> ccrIndexMetaD
334339
return historyUUIDs.split(",");
335340
}
336341

337-
private static final Set<Setting<?>> WHITE_LISTED_SETTINGS;
342+
/**
343+
* These are settings that are not replicated to the follower index and
344+
* therefor these settings are not validated whether they have the same
345+
* value between leader and follower index.
346+
*
347+
* These dynamic settings don't affect how documents are indexed (affect index time text analysis) and / or
348+
* are inconvenient if they were replicated (e.g. changing number of replicas).
349+
*/
350+
static final Set<Setting<?>> WHITE_LISTED_SETTINGS;
338351

339352
static {
340353
final Set<Setting<?>> whiteListedSettings = new HashSet<>();
341354
whiteListedSettings.add(IndexMetaData.INDEX_NUMBER_OF_REPLICAS_SETTING);
342355
whiteListedSettings.add(IndexMetaData.INDEX_AUTO_EXPAND_REPLICAS_SETTING);
343-
344356
whiteListedSettings.add(IndexMetaData.INDEX_ROUTING_EXCLUDE_GROUP_SETTING);
345357
whiteListedSettings.add(IndexMetaData.INDEX_ROUTING_INCLUDE_GROUP_SETTING);
346358
whiteListedSettings.add(IndexMetaData.INDEX_ROUTING_REQUIRE_GROUP_SETTING);
359+
whiteListedSettings.add(IndexMetaData.INDEX_READ_ONLY_SETTING);
360+
whiteListedSettings.add(IndexMetaData.INDEX_BLOCKS_READ_SETTING);
361+
whiteListedSettings.add(IndexMetaData.INDEX_BLOCKS_WRITE_SETTING);
362+
whiteListedSettings.add(IndexMetaData.INDEX_BLOCKS_METADATA_SETTING);
363+
whiteListedSettings.add(IndexMetaData.INDEX_BLOCKS_READ_ONLY_ALLOW_DELETE_SETTING);
364+
whiteListedSettings.add(IndexMetaData.INDEX_PRIORITY_SETTING);
365+
whiteListedSettings.add(IndexMetaData.SETTING_WAIT_FOR_ACTIVE_SHARDS);
366+
347367
whiteListedSettings.add(EnableAllocationDecider.INDEX_ROUTING_REBALANCE_ENABLE_SETTING);
348368
whiteListedSettings.add(EnableAllocationDecider.INDEX_ROUTING_ALLOCATION_ENABLE_SETTING);
349369
whiteListedSettings.add(ShardsLimitAllocationDecider.INDEX_TOTAL_SHARDS_PER_NODE_SETTING);
370+
whiteListedSettings.add(MaxRetryAllocationDecider.SETTING_ALLOCATION_MAX_RETRY);
371+
whiteListedSettings.add(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING);
350372

351-
whiteListedSettings.add(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING);
352373
whiteListedSettings.add(IndexSettings.MAX_RESULT_WINDOW_SETTING);
353374
whiteListedSettings.add(IndexSettings.INDEX_WARMER_ENABLED_SETTING);
354375
whiteListedSettings.add(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING);
@@ -359,6 +380,26 @@ static String[] extractLeaderShardHistoryUUIDs(Map<String, String> ccrIndexMetaD
359380
whiteListedSettings.add(IndexSettings.QUERY_STRING_ANALYZE_WILDCARD);
360381
whiteListedSettings.add(IndexSettings.QUERY_STRING_ALLOW_LEADING_WILDCARD);
361382
whiteListedSettings.add(IndexSettings.ALLOW_UNMAPPED);
383+
whiteListedSettings.add(IndexSettings.INDEX_SOFT_DELETES_RETENTION_OPERATIONS_SETTING);
384+
whiteListedSettings.add(IndexSettings.MAX_SCRIPT_FIELDS_SETTING);
385+
whiteListedSettings.add(IndexSettings.MAX_REGEX_LENGTH_SETTING);
386+
whiteListedSettings.add(IndexSettings.MAX_TERMS_COUNT_SETTING);
387+
whiteListedSettings.add(IndexSettings.MAX_ANALYZED_OFFSET_SETTING);
388+
whiteListedSettings.add(IndexSettings.MAX_DOCVALUE_FIELDS_SEARCH_SETTING);
389+
whiteListedSettings.add(IndexSettings.MAX_SLICES_PER_SCROLL);
390+
whiteListedSettings.add(IndexSettings.MAX_ADJACENCY_MATRIX_FILTERS_SETTING);
391+
whiteListedSettings.add(IndexSettings.DEFAULT_PIPELINE);
392+
whiteListedSettings.add(IndexSettings.INDEX_SEARCH_THROTTLED);
393+
whiteListedSettings.add(IndexSettings.INDEX_TRANSLOG_RETENTION_AGE_SETTING);
394+
whiteListedSettings.add(IndexSettings.INDEX_TRANSLOG_RETENTION_SIZE_SETTING);
395+
whiteListedSettings.add(IndexSettings.INDEX_TRANSLOG_GENERATION_THRESHOLD_SIZE_SETTING);
396+
whiteListedSettings.add(IndexSettings.INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING);
397+
whiteListedSettings.add(IndexSettings.INDEX_TRANSLOG_DURABILITY_SETTING);
398+
whiteListedSettings.add(IndexSettings.INDEX_GC_DELETES_SETTING);
399+
whiteListedSettings.add(IndexSettings.INDEX_TTL_DISABLE_PURGE_SETTING);
400+
whiteListedSettings.add(IndexSettings.MAX_REFRESH_LISTENERS_PER_SHARD);
401+
402+
whiteListedSettings.add(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING);
362403
whiteListedSettings.add(BitsetFilterCache.INDEX_LOAD_RANDOM_ACCESS_FILTERS_EAGERLY_SETTING);
363404

364405
whiteListedSettings.add(SearchSlowLog.INDEX_SEARCH_SLOWLOG_THRESHOLD_FETCH_DEBUG_SETTING);
@@ -378,7 +419,20 @@ static String[] extractLeaderShardHistoryUUIDs(Map<String, String> ccrIndexMetaD
378419
whiteListedSettings.add(IndexingSlowLog.INDEX_INDEXING_SLOWLOG_REFORMAT_SETTING);
379420
whiteListedSettings.add(IndexingSlowLog.INDEX_INDEXING_SLOWLOG_MAX_SOURCE_CHARS_TO_LOG_SETTING);
380421

381-
whiteListedSettings.add(IndexSettings.INDEX_SOFT_DELETES_RETENTION_OPERATIONS_SETTING);
422+
whiteListedSettings.add(MergePolicyConfig.INDEX_COMPOUND_FORMAT_SETTING);
423+
whiteListedSettings.add(MergePolicyConfig.INDEX_MERGE_POLICY_MAX_MERGE_AT_ONCE_SETTING);
424+
whiteListedSettings.add(MergePolicyConfig.INDEX_MERGE_POLICY_SEGMENTS_PER_TIER_SETTING);
425+
whiteListedSettings.add(MergePolicyConfig.INDEX_MERGE_POLICY_DELETES_PCT_ALLOWED_SETTING);
426+
whiteListedSettings.add(MergePolicyConfig.INDEX_MERGE_POLICY_EXPUNGE_DELETES_ALLOWED_SETTING);
427+
whiteListedSettings.add(MergePolicyConfig.INDEX_MERGE_POLICY_FLOOR_SEGMENT_SETTING);
428+
whiteListedSettings.add(MergePolicyConfig.INDEX_MERGE_POLICY_MAX_MERGE_AT_ONCE_EXPLICIT_SETTING);
429+
whiteListedSettings.add(MergePolicyConfig.INDEX_MERGE_POLICY_MAX_MERGED_SEGMENT_SETTING);
430+
whiteListedSettings.add(MergePolicyConfig.INDEX_MERGE_POLICY_RECLAIM_DELETES_WEIGHT_SETTING);
431+
432+
whiteListedSettings.add(MergeSchedulerConfig.AUTO_THROTTLE_SETTING);
433+
whiteListedSettings.add(MergeSchedulerConfig.MAX_MERGE_COUNT_SETTING);
434+
whiteListedSettings.add(MergeSchedulerConfig.MAX_THREAD_COUNT_SETTING);
435+
whiteListedSettings.add(EngineConfig.INDEX_CODEC_SETTING);
382436

383437
WHITE_LISTED_SETTINGS = Collections.unmodifiableSet(whiteListedSettings);
384438
}

x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/TransportResumeFollowActionTests.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@
99
import org.elasticsearch.Version;
1010
import org.elasticsearch.cluster.metadata.IndexMetaData;
1111
import org.elasticsearch.cluster.metadata.IndexMetaData.State;
12+
import org.elasticsearch.common.settings.IndexScopedSettings;
13+
import org.elasticsearch.common.settings.Setting;
1214
import org.elasticsearch.common.settings.Settings;
1315
import org.elasticsearch.index.IndexSettings;
1416
import org.elasticsearch.index.MapperTestUtils;
17+
import org.elasticsearch.index.engine.EngineConfig;
1518
import org.elasticsearch.index.mapper.MapperService;
1619
import org.elasticsearch.test.ESTestCase;
1720
import org.elasticsearch.xpack.ccr.Ccr;
@@ -21,11 +24,14 @@
2124

2225
import java.io.IOException;
2326
import java.util.HashMap;
27+
import java.util.HashSet;
2428
import java.util.Map;
29+
import java.util.Set;
2530

2631
import static java.util.Collections.singletonMap;
2732
import static org.elasticsearch.xpack.ccr.action.TransportResumeFollowAction.validate;
2833
import static org.hamcrest.Matchers.equalTo;
34+
import static org.hamcrest.Matchers.is;
2935

3036
public class TransportResumeFollowActionTests extends ESTestCase {
3137

@@ -202,6 +208,31 @@ public void testValidation() throws IOException {
202208
validate(request, leaderIMD, followIMD, UUIDs, mapperService);
203209
}
204210
}
211+
212+
public void testDynamicIndexSettingsAreClassified() {
213+
// We should be conscious which dynamic settings are replicated from leader to follower index.
214+
// This is the list of settings that should be replicated:
215+
Set<Setting<?>> replicatedSettings = new HashSet<>();
216+
217+
// These fields need to be replicated otherwise documents that can be indexed in the leader index cannot
218+
// be indexed in the follower index:
219+
replicatedSettings.add(MapperService.INDEX_MAPPING_TOTAL_FIELDS_LIMIT_SETTING);
220+
replicatedSettings.add(MapperService.INDEX_MAPPING_NESTED_FIELDS_LIMIT_SETTING);
221+
replicatedSettings.add(MapperService.INDEX_MAPPING_DEPTH_LIMIT_SETTING);
222+
replicatedSettings.add(MapperService.INDEX_MAPPER_DYNAMIC_SETTING);
223+
replicatedSettings.add(IndexSettings.MAX_NGRAM_DIFF_SETTING);
224+
replicatedSettings.add(IndexSettings.MAX_SHINGLE_DIFF_SETTING);
225+
replicatedSettings.add(EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS);
226+
227+
for (Setting<?> setting : IndexScopedSettings.BUILT_IN_INDEX_SETTINGS) {
228+
if (setting.isDynamic()) {
229+
boolean notReplicated = TransportResumeFollowAction.WHITE_LISTED_SETTINGS.contains(setting);
230+
boolean replicated = replicatedSettings.contains(setting);
231+
assertThat("setting [" + setting.getKey() + "] is not classified as replicated xor not replicated",
232+
notReplicated ^ replicated, is(true));
233+
}
234+
}
235+
}
205236

206237
private static IndexMetaData createIMD(String index,
207238
int numberOfShards,

0 commit comments

Comments
 (0)