Skip to content

Commit

Permalink
[Segment Replication] Introduce new SEGMENT_REPLICATION_EXPERIMENTAL …
Browse files Browse the repository at this point in the history
…feature flag. (opensearch-project#7006)

* Add new SEGMENT_REPLICATION_CLUSTER_SETTING feature flag.

Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com>

* Remove entry from changelog as the cluster setting introduced is noy ready for users to use.

Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com>

* Fix failing unit tests.

Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com>

* Address comments on PR.

Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com>

* Address comments on PR and chnage feature flag to SEGMENT_REPLICATION_EXPERIMENTAL.

Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com>

---------

Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com>
  • Loading branch information
Rishikesh1159 authored Apr 6, 2023
1 parent fe8253e commit fe8b4d4
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 16 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Add wait_for_completion parameter to resize, open, and forcemerge APIs ([#6434](https://github.com/opensearch-project/OpenSearch/pull/6434))
- [Segment Replication] Apply backpressure when replicas fall behind ([#6563](https://github.com/opensearch-project/OpenSearch/pull/6563))
- [Remote Store] Integrate remote segment store in peer recovery flow ([#6664](https://github.com/opensearch-project/OpenSearch/pull/6664))
- [Segment Replication] Add new cluster setting to set replication strategy by default for all indices in cluster. ([#6791](https://github.com/opensearch-project/OpenSearch/pull/6791))
- Enable sort optimization for all NumericTypes ([#6464](https://github.com/opensearch-project/OpenSearch/pull/6464)
- Remove 'cluster_manager' role attachment when using 'node.master' deprecated setting ([#6331](https://github.com/opensearch-project/OpenSearch/pull/6331))
- Add new cluster settings to ignore weighted round-robin routing and fallback to default behaviour. ([#6834](https://github.com/opensearch-project/OpenSearch/pull/6834))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ public Settings indexSettings() {

@Override
protected Settings featureFlagSettings() {
return Settings.builder().put(super.featureFlagSettings()).put(FeatureFlags.REPLICATION_TYPE, "true").build();
return Settings.builder()
.put(super.featureFlagSettings())
.put(FeatureFlags.SEGMENT_REPLICATION_EXPERIMENTAL, "true")
.put(FeatureFlags.REPLICATION_TYPE, "true")
.build();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,6 @@ public void validate(final Boolean value, final Map<Setting<?>, Object> settings
+ INDEX_REPLICATION_TYPE_SETTING.getKey()
+ " should be set to "
+ ReplicationType.SEGMENT
+ " or "
+ CLUSTER_REPLICATION_TYPE_SETTING.getKey()
+ " should be set to "
+ Boolean.TRUE
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ public void apply(Settings value, Settings current, Settings previous) {
public static final Map<String, List<Setting>> FEATURE_FLAGGED_CLUSTER_SETTINGS = Map.of(
FeatureFlags.SEARCHABLE_SNAPSHOT,
List.of(Node.NODE_SEARCH_CACHE_SIZE_SETTING),
FeatureFlags.REPLICATION_TYPE,
FeatureFlags.SEGMENT_REPLICATION_EXPERIMENTAL,
List.of(IndicesService.CLUSTER_REPLICATION_TYPE_SETTING)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ protected FeatureFlagSettings(
new HashSet<>(
Arrays.asList(
FeatureFlags.REPLICATION_TYPE_SETTING,
FeatureFlags.SEGMENT_REPLICATION_EXPERIMENTAL_SETTING,
FeatureFlags.REMOTE_STORE_SETTING,
FeatureFlags.SEARCHABLE_SNAPSHOT_SETTING,
FeatureFlags.EXTENSIONS_SETTING
Expand Down
12 changes: 12 additions & 0 deletions server/src/main/java/org/opensearch/common/util/FeatureFlags.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ public class FeatureFlags {
*/
public static final String REPLICATION_TYPE = "opensearch.experimental.feature.replication_type.enabled";

/**
* Gates the visibility of the segment replication experimental features that allows users to test unreleased beta features.
*/
public static final String SEGMENT_REPLICATION_EXPERIMENTAL =
"opensearch.experimental.feature.segment_replication_experimental.enabled";

/**
* Gates the visibility of the index setting that allows persisting data to remote store along with local disk.
* Once the feature is ready for production release, this feature flag can be removed.
Expand Down Expand Up @@ -84,6 +90,12 @@ public static boolean isEnabled(String featureFlagName) {

public static final Setting<Boolean> REPLICATION_TYPE_SETTING = Setting.boolSetting(REPLICATION_TYPE, false, Property.NodeScope);

public static final Setting<Boolean> SEGMENT_REPLICATION_EXPERIMENTAL_SETTING = Setting.boolSetting(
SEGMENT_REPLICATION_EXPERIMENTAL,
false,
Property.NodeScope
);

public static final Setting<Boolean> REMOTE_STORE_SETTING = Setting.boolSetting(REMOTE_STORE, false, Property.NodeScope);

public static final Setting<Boolean> SEARCHABLE_SNAPSHOT_SETTING = Setting.boolSetting(SEARCHABLE_SNAPSHOT, false, Property.NodeScope);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ public IndexSettings(final IndexMetadata indexMetadata, final Settings nodeSetti
nodeName = Node.NODE_NAME_SETTING.get(settings);
this.indexMetadata = indexMetadata;
numberOfShards = settings.getAsInt(IndexMetadata.SETTING_NUMBER_OF_SHARDS, null);
if (FeatureFlags.isEnabled(FeatureFlags.REPLICATION_TYPE)
if (FeatureFlags.isEnabled(FeatureFlags.SEGMENT_REPLICATION_EXPERIMENTAL)
&& indexMetadata.isSystem() == false
&& settings.get(IndexMetadata.SETTING_REPLICATION_TYPE) == null) {
replicationType = IndicesService.CLUSTER_REPLICATION_TYPE_SETTING.get(settings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -869,10 +869,7 @@ public void testEnablingRemoteStoreFailsWhenReplicationTypeIsDocument() {
IllegalArgumentException.class,
() -> IndexMetadata.INDEX_REMOTE_STORE_ENABLED_SETTING.get(indexSettings)
);
assertEquals(
"To enable index.remote_store.enabled, index.replication.type should be set to SEGMENT or cluster.indices.replication.strategy should be set to true",
iae.getMessage()
);
assertEquals("To enable index.remote_store.enabled, index.replication.type should be set to SEGMENT", iae.getMessage());
}

public void testEnablingRemoteStoreFailsWhenReplicationTypeIsDefault() {
Expand All @@ -881,10 +878,7 @@ public void testEnablingRemoteStoreFailsWhenReplicationTypeIsDefault() {
IllegalArgumentException.class,
() -> IndexMetadata.INDEX_REMOTE_STORE_ENABLED_SETTING.get(indexSettings)
);
assertEquals(
"To enable index.remote_store.enabled, index.replication.type should be set to SEGMENT or cluster.indices.replication.strategy should be set to true",
iae.getMessage()
);
assertEquals("To enable index.remote_store.enabled, index.replication.type should be set to SEGMENT", iae.getMessage());
}

public void testRemoteRepositoryDefaultSetting() {
Expand Down

0 comments on commit fe8b4d4

Please sign in to comment.