-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Segment Replication] Add setting to enable segment replication as default replication type. #6791
[Segment Replication] Add setting to enable segment replication as default replication type. #6791
Conversation
Signed-off-by: Rishikesh1159 <[email protected]>
Gradle Check (Jenkins) Run Completed with:
|
Signed-off-by: Rishikesh1159 <[email protected]>
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertHitCount; | ||
|
||
@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, numDataNodes = 0) | ||
public class SegmentReplicationDefaultIT extends OpenSearchIntegTestCase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SegmentReplicationDefaultIT doesn't tell us that this file is related to the setting. I would suggest renaming it to SegmentReplicationDefaultClusterSettingIT instead.
// Verify that Segment Replication happened on the replica shard. | ||
assertFalse(segmentReplicationStatsResponse.getReplicationStats().get(indexName).get(0).getReplicaStats().isEmpty()); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could add some more tests here to test the behavior described:
- A test to ensure that when cluster setting for segrep is true, creating an index with docrep enabled overrides this cluster setting.
- Similarly a test to ensure overriding takes place when index.replication.type is set to docrep when the segrep cluster setting is true.
- A last test (optional) to check that when the feature flag is not enabled, even setting the cluster setting doesn't result in segment replication indices.
@@ -282,6 +282,16 @@ public Iterator<Setting<?>> settings() { | |||
Property.IndexScope | |||
); | |||
|
|||
/** | |||
* Used to specify SEGMENT replication type as default for all indices. By default, this is false. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
* Used to specify SEGMENT replication type as default for all indices. By default, this is false. | |
* Used to specify SEGMENT replication type as the default replication strategy for all indices in a cluster. By default, this is false. |
/** | ||
* Used to specify SEGMENT replication type as default for all indices. By default, this is false. | ||
*/ | ||
public static final Setting<Boolean> DEFAULT_REPLICATION_TYPE_SETTING_SEGMENT = Setting.boolSetting( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be renamed to DEFAULT_SEGMENT_REPLICATION_TYPE_CLUSTER_SETTING or CLUSTER_DEFAULT_SEGMENT_REPLICATION_TYPE_SETTING to make it obvious this is a cluster level setting.
* Used to specify SEGMENT replication type as default for all indices. By default, this is false. | ||
*/ | ||
public static final Setting<Boolean> DEFAULT_REPLICATION_TYPE_SETTING_SEGMENT = Setting.boolSetting( | ||
"opensearch.index.default.replication.type.segment", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rename it to something along the lines of indices.replication.strategy
and set the default value to doc rep (preferably using an enum). The user can then set it to seg_rep
as needed.
I would also move it under IndicesService
similar to -
OpenSearch/server/src/main/java/org/opensearch/indices/IndicesService.java
Lines 214 to 219 in f40fa82
public static final String INDICES_SHARDS_CLOSED_TIMEOUT = "indices.shards_closed_timeout"; | |
public static final Setting<TimeValue> INDICES_CACHE_CLEAN_INTERVAL_SETTING = Setting.positiveTimeSetting( | |
"indices.cache.cleanup_interval", | |
TimeValue.timeValueMinutes(1), | |
Property.NodeScope | |
); |
Gradle Check (Jenkins) Run Completed with:
|
Looks like a legit failure.
|
Signed-off-by: Rishikesh1159 <[email protected]>
Signed-off-by: Rishikesh1159 <[email protected]>
Gradle Check (Jenkins) Run Completed with:
|
Signed-off-by: Rishikesh1159 <[email protected]>
Gradle Check (Jenkins) Run Completed with:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a few more comments.
Also add a CHANGELOG
entry since you are introducing a new configuration.
final Object replicationType = settings.get(INDEX_REPLICATION_TYPE_SETTING); | ||
if (replicationType != ReplicationType.SEGMENT && value == true) { | ||
if (replicationType != ReplicationType.SEGMENT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: use !ReplicationType.SEGMENT.equals(replicationType)
for safer usage
*/ | ||
public static final String CLUSTER_SETTING_REPLICATION_TYPE = "cluster.indices.replication.strategy"; | ||
|
||
public static final Setting<ReplicationType> CLUSTER_DEFAULT_REPLICATION_TYPE_SETTING = new Setting<>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CLUSTER_REPLICATION_TYPE_SETTING
seems more appropriate here. Default is implied by the default value that will be provided. Also would need documentation around this to demonstrate the hierarchy of CLUSTER_REPLICATION_TYPE_SETTING
and INDEX_REPLICATION_TYPE_SETTING
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I will update that. Yes, I will open an issue in documentation repo to document this changes once this PR is merged.
Signed-off-by: Rishikesh1159 <[email protected]>
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## main #6791 +/- ##
============================================
+ Coverage 70.65% 70.80% +0.15%
- Complexity 59184 59240 +56
============================================
Files 4810 4810
Lines 283487 283498 +11
Branches 40877 40882 +5
============================================
+ Hits 200299 200740 +441
+ Misses 66761 66274 -487
- Partials 16427 16484 +57
... and 527 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
if (FeatureFlags.isEnabled(FeatureFlags.REPLICATION_TYPE) | ||
&& indexMetadata.isSystem() == false | ||
&& settings.get(IndexMetadata.SETTING_REPLICATION_TYPE) == null) { | ||
replicationType = ReplicationType.parseString(settings.get(IndicesService.CLUSTER_SETTING_REPLICATION_TYPE)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: This can be replaced by
replicationType = ReplicationType.parseString(settings.get(IndicesService.CLUSTER_SETTING_REPLICATION_TYPE)); | |
replicationType = IndicesService.CLUSTER_REPLICATION_TYPE_SETTING.get(settings); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I will update this
&& settings.get(IndexMetadata.SETTING_REPLICATION_TYPE) == null) { | ||
replicationType = ReplicationType.parseString(settings.get(IndicesService.CLUSTER_SETTING_REPLICATION_TYPE)); | ||
} else { | ||
replicationType = ReplicationType.parseString(settings.get(IndexMetadata.SETTING_REPLICATION_TYPE)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: This can be replaced by
replicationType = ReplicationType.parseString(settings.get(IndexMetadata.SETTING_REPLICATION_TYPE)); | |
replicationType = IndexMetadata.INDEX_REPLICATION_TYPE_SETTING.get(settings).get(settings); |
Signed-off-by: Rishikesh1159 <[email protected]>
…1159/OpenSearch into default-segrep-setting
Gradle Check (Jenkins) Run Completed with:
|
…fault replication type. (#6791) * Add setting to enable segment replication as default replication type. Signed-off-by: Rishikesh1159 <[email protected]> * Fix failing unit tests. Signed-off-by: Rishikesh1159 <[email protected]> * Address comments on PR. Signed-off-by: Rishikesh1159 <[email protected]> * Address comments. Signed-off-by: Rishikesh1159 <[email protected]> * Fix failing unit test. Signed-off-by: Rishikesh1159 <[email protected]> * Address comments. Signed-off-by: Rishikesh1159 <[email protected]> * Refactoring PR. Signed-off-by: Rishikesh1159 <[email protected]> --------- Signed-off-by: Rishikesh1159 <[email protected]> (cherry picked from commit 879ade7) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
…fault replication type. (#6791) (#6812) * Add setting to enable segment replication as default replication type. * Fix failing unit tests. * Address comments on PR. * Address comments. * Fix failing unit test. * Address comments. * Refactoring PR. --------- (cherry picked from commit 879ade7) Signed-off-by: Rishikesh1159 <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Currently, when user set cluster setting |
…fault replication type. (opensearch-project#6791) * Add setting to enable segment replication as default replication type. Signed-off-by: Rishikesh1159 <[email protected]> * Fix failing unit tests. Signed-off-by: Rishikesh1159 <[email protected]> * Address comments on PR. Signed-off-by: Rishikesh1159 <[email protected]> * Address comments. Signed-off-by: Rishikesh1159 <[email protected]> * Fix failing unit test. Signed-off-by: Rishikesh1159 <[email protected]> * Address comments. Signed-off-by: Rishikesh1159 <[email protected]> * Refactoring PR. Signed-off-by: Rishikesh1159 <[email protected]> --------- Signed-off-by: Rishikesh1159 <[email protected]> Signed-off-by: Valentin Mitrofanov <[email protected]>
Description
This PR adds setting for users to enable segment replication as default replication strategy.
-> This setting is a static setting and can only be enable through configuration and not by REST API's.
-> When this setting is enabled it makes all new indices in cluster use segment replication as default replication type. But users can still create an index using document replication by passing replication type as DOCUMENT during index creation. As Index level settings always override cluster level settings.
-> Not only during index creation but also if users set
"index.replication.type"
in configuration file, as it is an index level setting it will override the new setting of default segment replication.-> This setting is not applied for system indices. By default all system indices in opensearch will still use document replication even if this setting is enabled.
-> This setting is still behind a Segment Replication Feature flag. So, users have to still enable feature flag for this setting to work. Once feature flag is removed users can set this setting directly.
Issues Resolved
Resolves #6656
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.