Skip to content

Commit cc2a023

Browse files
committed
[8.x] Remove synthetic recovery source feature flag.
Backporting elastic#122615 to 8.branch. This feature flag controls whether synthetic recovery source is enabled by default when the source mode is synthetic. The synthetic recovery source feature itself is already available via the index.recovery.use_synthetic_source index setting and can be enabled by anyone using synthetic source. The default value of index.recovery.use_synthetic_source setting defaults to true when index.mapping.source.mode is enabled. The index.mapping.source.mode default to true if index.mode is logsdb or time_series. In other words, with this change synthetic recovery source will be enabled by default for logsdb and tsdb. Closes elastic#116726
1 parent 9c92281 commit cc2a023

File tree

9 files changed

+19
-81
lines changed

9 files changed

+19
-81
lines changed

docs/changelog/122615.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
pr: 122615
2+
summary: Enable synthetic recovery source by default when synthetic source is enabled.
3+
Using synthetic recovery source significantly improves indexing performance compared
4+
to regular recovery source.
5+
area: Mapping
6+
type: enhancement
7+
issues:
8+
- 116726

qa/smoke-test-multinode/src/yamlRestTest/java/org/elasticsearch/smoketest/SmokeTestMultiNodeClientYamlTestSuiteIT.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public class SmokeTestMultiNodeClientYamlTestSuiteIT extends ESClientYamlSuiteTe
3636
.node(0, n -> n.setting("node.roles", "[master,data,ml,remote_cluster_client,transform]"))
3737
.feature(FeatureFlag.TIME_SERIES_MODE)
3838
.feature(FeatureFlag.SUB_OBJECTS_AUTO_ENABLED)
39-
.feature(FeatureFlag.INDEX_RECOVERY_USE_SYNTHETIC_SOURCE)
4039
.build();
4140

4241
public SmokeTestMultiNodeClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {

rest-api-spec/src/yamlRestTest/java/org/elasticsearch/test/rest/ClientYamlTestSuiteIT.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public class ClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
3737
.module("data-streams")
3838
.feature(FeatureFlag.TIME_SERIES_MODE)
3939
.feature(FeatureFlag.SUB_OBJECTS_AUTO_ENABLED)
40-
.feature(FeatureFlag.INDEX_RECOVERY_USE_SYNTHETIC_SOURCE)
4140
.build();
4241

4342
public ClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {

server/src/main/java/org/elasticsearch/index/IndexSettings.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -727,14 +727,11 @@ public Iterator<Setting<?>> settings() {
727727
Setting.Property.IndexScope
728728
);
729729

730-
public static final FeatureFlag RECOVERY_USE_SYNTHETIC_SOURCE = new FeatureFlag("index_recovery_use_synthetic_source");
731730
public static final Setting<Boolean> RECOVERY_USE_SYNTHETIC_SOURCE_SETTING = Setting.boolSetting(
732731
"index.recovery.use_synthetic_source",
733732
settings -> {
734-
boolean isSyntheticSourceRecoveryFeatureFlagEnabled = RECOVERY_USE_SYNTHETIC_SOURCE.isEnabled();
735-
boolean isNewIndexVersion = SETTING_INDEX_VERSION_CREATED.get(settings)
733+
boolean useSyntheticRecoverySource = SETTING_INDEX_VERSION_CREATED.get(settings)
736734
.onOrAfter(IndexVersions.USE_SYNTHETIC_SOURCE_FOR_RECOVERY_BY_DEFAULT_BACKPORT);
737-
boolean useSyntheticRecoverySource = isSyntheticSourceRecoveryFeatureFlagEnabled && isNewIndexVersion;
738735
return String.valueOf(
739736
useSyntheticRecoverySource
740737
&& Objects.equals(INDEX_MAPPER_SOURCE_MODE_SETTING.get(settings), SourceFieldMapper.Mode.SYNTHETIC)

server/src/test/java/org/elasticsearch/index/mapper/NativeArrayIntegrationTestCase.java

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import org.elasticsearch.action.support.WriteRequest;
2121
import org.elasticsearch.common.network.NetworkAddress;
2222
import org.elasticsearch.common.settings.Settings;
23-
import org.elasticsearch.index.IndexSettings;
2423
import org.elasticsearch.index.query.IdsQueryBuilder;
2524
import org.elasticsearch.test.ESSingleNodeTestCase;
2625
import org.elasticsearch.xcontent.XContentBuilder;
@@ -35,7 +34,6 @@
3534

3635
import static org.elasticsearch.xcontent.XContentFactory.jsonBuilder;
3736
import static org.hamcrest.Matchers.contains;
38-
import static org.hamcrest.Matchers.containsInAnyOrder;
3937
import static org.hamcrest.Matchers.empty;
4038
import static org.hamcrest.Matchers.equalTo;
4139
import static org.hamcrest.Matchers.hasKey;
@@ -136,14 +134,7 @@ protected void verifySyntheticArray(Object[][] arrays, XContentBuilder mapping,
136134
var document = reader.storedFields().document(i);
137135
// Verify that there is no ignored source:
138136
Set<String> storedFieldNames = new LinkedHashSet<>(document.getFields().stream().map(IndexableField::name).toList());
139-
if (IndexSettings.RECOVERY_USE_SYNTHETIC_SOURCE.isEnabled()) {
140-
assertThat(storedFieldNames, contains(expectedStoredFields));
141-
} else {
142-
var copyExpectedStoredFields = new String[expectedStoredFields.length + 1];
143-
System.arraycopy(expectedStoredFields, 0, copyExpectedStoredFields, 0, expectedStoredFields.length);
144-
copyExpectedStoredFields[copyExpectedStoredFields.length - 1] = "_recovery_source";
145-
assertThat(storedFieldNames, containsInAnyOrder(copyExpectedStoredFields));
146-
}
137+
assertThat(storedFieldNames, contains(expectedStoredFields));
147138
}
148139
var fieldInfo = FieldInfos.getMergedFieldInfos(reader).fieldInfo("field.offsets");
149140
assertThat(fieldInfo.getDocValuesType(), equalTo(DocValuesType.SORTED));
@@ -208,11 +199,7 @@ protected void verifySyntheticObjectArray(List<List<Object[]>> documents) throws
208199
var document = reader.storedFields().document(i);
209200
// Verify that there is ignored source because of leaf array being wrapped by object array:
210201
List<String> storedFieldNames = document.getFields().stream().map(IndexableField::name).toList();
211-
if (IndexSettings.RECOVERY_USE_SYNTHETIC_SOURCE.isEnabled()) {
212-
assertThat(storedFieldNames, contains("_id", "_ignored_source"));
213-
} else {
214-
assertThat(storedFieldNames, containsInAnyOrder("_id", "_ignored_source", "_recovery_source"));
215-
}
202+
assertThat(storedFieldNames, contains("_id", "_ignored_source"));
216203

217204
// Verify that there is no offset field:
218205
LeafReader leafReader = reader.leaves().get(0).reader();
@@ -285,11 +272,7 @@ protected void verifySyntheticArrayInObject(List<Object[]> documents) throws IOE
285272
var document = reader.storedFields().document(i);
286273
// Verify that there is no ignored source:
287274
Set<String> storedFieldNames = new LinkedHashSet<>(document.getFields().stream().map(IndexableField::name).toList());
288-
if (IndexSettings.RECOVERY_USE_SYNTHETIC_SOURCE.isEnabled()) {
289-
assertThat(storedFieldNames, contains("_id"));
290-
} else {
291-
assertThat(storedFieldNames, containsInAnyOrder("_id", "_recovery_source"));
292-
}
275+
assertThat(storedFieldNames, contains("_id"));
293276
}
294277
var fieldInfo = FieldInfos.getMergedFieldInfos(reader).fieldInfo("object.field.offsets");
295278
assertThat(fieldInfo.getDocValuesType(), equalTo(DocValuesType.SORTED));

server/src/test/java/org/elasticsearch/index/mapper/SourceFieldMapperTests.java

Lines changed: 6 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -475,13 +475,7 @@ public void testRecoverySourceWithSyntheticSource() throws IOException {
475475
MapperService mapperService = createMapperService(settings, topMapping(b -> {}));
476476
DocumentMapper docMapper = mapperService.documentMapper();
477477
ParsedDocument doc = docMapper.parse(source(b -> b.field("field1", "value1")));
478-
if (IndexSettings.RECOVERY_USE_SYNTHETIC_SOURCE.isEnabled() == false) {
479-
// TODO: remove this if branch when removing the 'index_recovery_use_synthetic_source' feature flag
480-
assertNotNull(doc.rootDoc().getField("_recovery_source"));
481-
assertThat(doc.rootDoc().getField("_recovery_source").binaryValue(), equalTo(new BytesRef("{\"field1\":\"value1\"}")));
482-
} else {
483-
assertNull(doc.rootDoc().getField("_recovery_source"));
484-
}
478+
assertNull(doc.rootDoc().getField("_recovery_source"));
485479
}
486480
{
487481
Settings settings = Settings.builder()
@@ -512,16 +506,8 @@ public void testRecoverySourceWithLogs() throws IOException {
512506
MapperService mapperService = createMapperService(settings, mapping(b -> {}));
513507
DocumentMapper docMapper = mapperService.documentMapper();
514508
ParsedDocument doc = docMapper.parse(source(b -> { b.field("@timestamp", "2012-02-13"); }));
515-
if (IndexSettings.RECOVERY_USE_SYNTHETIC_SOURCE.isEnabled() == false) {
516-
// TODO: remove this if branch when removing the 'index_recovery_use_synthetic_source' feature flag
517-
assertNotNull(doc.rootDoc().getField("_recovery_source"));
518-
assertThat(
519-
doc.rootDoc().getField("_recovery_source").binaryValue(),
520-
equalTo(new BytesRef("{\"@timestamp\":\"2012-02-13\"}"))
521-
);
522-
} else {
523-
assertNull(doc.rootDoc().getField("_recovery_source"));
524-
}
509+
assertNotNull(doc.rootDoc().getField("_recovery_source_size"));
510+
assertThat(doc.rootDoc().getField("_recovery_source_size").numericValue(), equalTo(27L));
525511
}
526512
{
527513
Settings settings = Settings.builder()
@@ -714,16 +700,7 @@ public void testRecoverySourceWithLogsCustom() throws IOException {
714700
MapperService mapperService = createMapperService(settings, mappings);
715701
DocumentMapper docMapper = mapperService.documentMapper();
716702
ParsedDocument doc = docMapper.parse(source(b -> { b.field("@timestamp", "2012-02-13"); }));
717-
if (IndexSettings.RECOVERY_USE_SYNTHETIC_SOURCE.isEnabled() == false) {
718-
// TODO: remove this if branch when removing the 'index_recovery_use_synthetic_source' feature flag
719-
assertNotNull(doc.rootDoc().getField("_recovery_source"));
720-
assertThat(
721-
doc.rootDoc().getField("_recovery_source").binaryValue(),
722-
equalTo(new BytesRef("{\"@timestamp\":\"2012-02-13\"}"))
723-
);
724-
} else {
725-
assertNull(doc.rootDoc().getField("_recovery_source"));
726-
}
703+
assertNull(doc.rootDoc().getField("_recovery_source"));
727704
}
728705
{
729706
Settings settings = Settings.builder()
@@ -749,16 +726,7 @@ public void testRecoverySourceWithTimeSeries() throws IOException {
749726
}));
750727
DocumentMapper docMapper = mapperService.documentMapper();
751728
ParsedDocument doc = docMapper.parse(source("123", b -> b.field("@timestamp", "2012-02-13").field("field", "value1"), null));
752-
if (IndexSettings.RECOVERY_USE_SYNTHETIC_SOURCE.isEnabled() == false) {
753-
// TODO: remove this if branch when removing the 'index_recovery_use_synthetic_source' feature flag
754-
assertNotNull(doc.rootDoc().getField("_recovery_source"));
755-
assertThat(
756-
doc.rootDoc().getField("_recovery_source").binaryValue(),
757-
equalTo(new BytesRef("{\"@timestamp\":\"2012-02-13\",\"field\":\"value1\"}"))
758-
);
759-
} else {
760-
assertNull(doc.rootDoc().getField("_recovery_source"));
761-
}
729+
assertNull(doc.rootDoc().getField("_recovery_source"));
762730
}
763731
{
764732
Settings settings = Settings.builder()
@@ -802,16 +770,7 @@ public void testRecoverySourceWithTimeSeriesCustom() throws IOException {
802770
MapperService mapperService = createMapperService(settings, mappings);
803771
DocumentMapper docMapper = mapperService.documentMapper();
804772
ParsedDocument doc = docMapper.parse(source("123", b -> b.field("@timestamp", "2012-02-13").field("field", "value1"), null));
805-
if (IndexSettings.RECOVERY_USE_SYNTHETIC_SOURCE.isEnabled() == false) {
806-
// TODO: remove this if branch when removing the 'index_recovery_use_synthetic_source' feature flag
807-
assertNotNull(doc.rootDoc().getField("_recovery_source"));
808-
assertThat(
809-
doc.rootDoc().getField("_recovery_source").binaryValue(),
810-
equalTo(new BytesRef("{\"@timestamp\":\"2012-02-13\",\"field\":\"value1\"}"))
811-
);
812-
} else {
813-
assertNull(doc.rootDoc().getField("_recovery_source"));
814-
}
773+
assertNull(doc.rootDoc().getField("_recovery_source"));
815774
}
816775
{
817776
Settings settings = Settings.builder()

test/test-clusters/src/main/java/org/elasticsearch/test/cluster/FeatureFlag.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,7 @@
1818
public enum FeatureFlag {
1919
TIME_SERIES_MODE("es.index_mode_feature_flag_registered=true", Version.fromString("8.0.0"), null),
2020
FAILURE_STORE_ENABLED("es.failure_store_feature_flag_enabled=true", Version.fromString("8.12.0"), null),
21-
SUB_OBJECTS_AUTO_ENABLED("es.sub_objects_auto_feature_flag_enabled=true", Version.fromString("8.16.0"), null),
22-
INDEX_RECOVERY_USE_SYNTHETIC_SOURCE(
23-
"es.index_recovery_use_synthetic_source_feature_flag_enabled=true",
24-
Version.fromString("8.18.0"),
25-
null
26-
);
21+
SUB_OBJECTS_AUTO_ENABLED("es.sub_objects_auto_feature_flag_enabled=true", Version.fromString("8.16.0"), null);
2722

2823
public final String systemProperty;
2924
public final Version from;

x-pack/plugin/logsdb/src/yamlRestTest/java/org/elasticsearch/xpack/logsdb/LogsdbTestSuiteIT.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public class LogsdbTestSuiteIT extends ESClientYamlSuiteTestCase {
2424
.distribution(DistributionType.DEFAULT)
2525
.setting("xpack.security.enabled", "false")
2626
.setting("xpack.license.self_generated.type", "trial")
27-
.feature(FeatureFlag.INDEX_RECOVERY_USE_SYNTHETIC_SOURCE)
2827
.build();
2928

3029
public LogsdbTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {

x-pack/qa/core-rest-tests-with-security/src/yamlRestTest/java/org/elasticsearch/xpack/security/CoreWithSecurityClientYamlTestSuiteIT.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public class CoreWithSecurityClientYamlTestSuiteIT extends ESClientYamlSuiteTest
5050
.user(USER, PASS)
5151
.feature(FeatureFlag.TIME_SERIES_MODE)
5252
.feature(FeatureFlag.SUB_OBJECTS_AUTO_ENABLED)
53-
.feature(FeatureFlag.INDEX_RECOVERY_USE_SYNTHETIC_SOURCE)
5453
.build();
5554

5655
public CoreWithSecurityClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {

0 commit comments

Comments
 (0)