Skip to content

Commit 26de534

Browse files
authored
Remove synthetic recovery source feature flag. (#122615)
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 #116726
1 parent 2456cd3 commit 26de534

File tree

9 files changed

+18
-81
lines changed

9 files changed

+18
-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
.feature(FeatureFlag.DOC_VALUES_SKIPPER)
4140
.build();
4241

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
@@ -36,7 +36,6 @@ public class ClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
3636
.module("data-streams")
3737
.feature(FeatureFlag.TIME_SERIES_MODE)
3838
.feature(FeatureFlag.SUB_OBJECTS_AUTO_ENABLED)
39-
.feature(FeatureFlag.INDEX_RECOVERY_USE_SYNTHETIC_SOURCE)
4039
.feature(FeatureFlag.DOC_VALUES_SKIPPER)
4140
.build();
4241

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -732,19 +732,15 @@ public Iterator<Setting<?>> settings() {
732732
Setting.Property.ServerlessPublic
733733
);
734734

735-
public static final FeatureFlag RECOVERY_USE_SYNTHETIC_SOURCE = new FeatureFlag("index_recovery_use_synthetic_source");
736735
public static final Setting<Boolean> RECOVERY_USE_SYNTHETIC_SOURCE_SETTING = Setting.boolSetting(
737736
"index.recovery.use_synthetic_source",
738737
settings -> {
739-
boolean isSyntheticSourceRecoveryFeatureFlagEnabled = RECOVERY_USE_SYNTHETIC_SOURCE.isEnabled();
740738
boolean isNewIndexVersion = SETTING_INDEX_VERSION_CREATED.get(settings)
741739
.onOrAfter(IndexVersions.USE_SYNTHETIC_SOURCE_FOR_RECOVERY_BY_DEFAULT);
742740
boolean isIndexVersionInBackportRange = SETTING_INDEX_VERSION_CREATED.get(settings)
743741
.between(IndexVersions.USE_SYNTHETIC_SOURCE_FOR_RECOVERY_BY_DEFAULT_BACKPORT, IndexVersions.UPGRADE_TO_LUCENE_10_0_0);
744742

745-
boolean useSyntheticRecoverySource = isSyntheticSourceRecoveryFeatureFlagEnabled
746-
&& (isNewIndexVersion || isIndexVersionInBackportRange);
747-
743+
boolean useSyntheticRecoverySource = isNewIndexVersion || isIndexVersionInBackportRange;
748744
return String.valueOf(
749745
useSyntheticRecoverySource
750746
&& 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
@@ -489,13 +489,7 @@ public void testRecoverySourceWithSyntheticSource() throws IOException {
489489
MapperService mapperService = createMapperService(settings, topMapping(b -> {}));
490490
DocumentMapper docMapper = mapperService.documentMapper();
491491
ParsedDocument doc = docMapper.parse(source(b -> b.field("field1", "value1")));
492-
if (IndexSettings.RECOVERY_USE_SYNTHETIC_SOURCE.isEnabled() == false) {
493-
// TODO: remove this if branch when removing the 'index_recovery_use_synthetic_source' feature flag
494-
assertNotNull(doc.rootDoc().getField("_recovery_source"));
495-
assertThat(doc.rootDoc().getField("_recovery_source").binaryValue(), equalTo(new BytesRef("{\"field1\":\"value1\"}")));
496-
} else {
497-
assertNull(doc.rootDoc().getField("_recovery_source"));
498-
}
492+
assertNull(doc.rootDoc().getField("_recovery_source"));
499493
}
500494
{
501495
Settings settings = Settings.builder()
@@ -526,16 +520,8 @@ public void testRecoverySourceWithLogs() throws IOException {
526520
MapperService mapperService = createMapperService(settings, mapping(b -> {}));
527521
DocumentMapper docMapper = mapperService.documentMapper();
528522
ParsedDocument doc = docMapper.parse(source(b -> { b.field("@timestamp", "2012-02-13"); }));
529-
if (IndexSettings.RECOVERY_USE_SYNTHETIC_SOURCE.isEnabled() == false) {
530-
// TODO: remove this if branch when removing the 'index_recovery_use_synthetic_source' feature flag
531-
assertNotNull(doc.rootDoc().getField("_recovery_source"));
532-
assertThat(
533-
doc.rootDoc().getField("_recovery_source").binaryValue(),
534-
equalTo(new BytesRef("{\"@timestamp\":\"2012-02-13\"}"))
535-
);
536-
} else {
537-
assertNull(doc.rootDoc().getField("_recovery_source"));
538-
}
523+
assertNotNull(doc.rootDoc().getField("_recovery_source_size"));
524+
assertThat(doc.rootDoc().getField("_recovery_source_size").numericValue(), equalTo(27L));
539525
}
540526
{
541527
Settings settings = Settings.builder()
@@ -728,16 +714,7 @@ public void testRecoverySourceWithLogsCustom() throws IOException {
728714
MapperService mapperService = createMapperService(settings, mappings);
729715
DocumentMapper docMapper = mapperService.documentMapper();
730716
ParsedDocument doc = docMapper.parse(source(b -> { b.field("@timestamp", "2012-02-13"); }));
731-
if (IndexSettings.RECOVERY_USE_SYNTHETIC_SOURCE.isEnabled() == false) {
732-
// TODO: remove this if branch when removing the 'index_recovery_use_synthetic_source' feature flag
733-
assertNotNull(doc.rootDoc().getField("_recovery_source"));
734-
assertThat(
735-
doc.rootDoc().getField("_recovery_source").binaryValue(),
736-
equalTo(new BytesRef("{\"@timestamp\":\"2012-02-13\"}"))
737-
);
738-
} else {
739-
assertNull(doc.rootDoc().getField("_recovery_source"));
740-
}
717+
assertNull(doc.rootDoc().getField("_recovery_source"));
741718
}
742719
{
743720
Settings settings = Settings.builder()
@@ -763,16 +740,7 @@ public void testRecoverySourceWithTimeSeries() throws IOException {
763740
}));
764741
DocumentMapper docMapper = mapperService.documentMapper();
765742
ParsedDocument doc = docMapper.parse(source("123", b -> b.field("@timestamp", "2012-02-13").field("field", "value1"), null));
766-
if (IndexSettings.RECOVERY_USE_SYNTHETIC_SOURCE.isEnabled() == false) {
767-
// TODO: remove this if branch when removing the 'index_recovery_use_synthetic_source' feature flag
768-
assertNotNull(doc.rootDoc().getField("_recovery_source"));
769-
assertThat(
770-
doc.rootDoc().getField("_recovery_source").binaryValue(),
771-
equalTo(new BytesRef("{\"@timestamp\":\"2012-02-13\",\"field\":\"value1\"}"))
772-
);
773-
} else {
774-
assertNull(doc.rootDoc().getField("_recovery_source"));
775-
}
743+
assertNull(doc.rootDoc().getField("_recovery_source"));
776744
}
777745
{
778746
Settings settings = Settings.builder()
@@ -816,16 +784,7 @@ public void testRecoverySourceWithTimeSeriesCustom() throws IOException {
816784
MapperService mapperService = createMapperService(settings, mappings);
817785
DocumentMapper docMapper = mapperService.documentMapper();
818786
ParsedDocument doc = docMapper.parse(source("123", b -> b.field("@timestamp", "2012-02-13").field("field", "value1"), null));
819-
if (IndexSettings.RECOVERY_USE_SYNTHETIC_SOURCE.isEnabled() == false) {
820-
// TODO: remove this if branch when removing the 'index_recovery_use_synthetic_source' feature flag
821-
assertNotNull(doc.rootDoc().getField("_recovery_source"));
822-
assertThat(
823-
doc.rootDoc().getField("_recovery_source").binaryValue(),
824-
equalTo(new BytesRef("{\"@timestamp\":\"2012-02-13\",\"field\":\"value1\"}"))
825-
);
826-
} else {
827-
assertNull(doc.rootDoc().getField("_recovery_source"));
828-
}
787+
assertNull(doc.rootDoc().getField("_recovery_source"));
829788
}
830789
{
831790
Settings settings = Settings.builder()

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ 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),
2121
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-
),
2722
DOC_VALUES_SKIPPER("es.doc_values_skipper_feature_flag_enabled=true", Version.fromString("8.18.1"), null);
2823

2924
public final String systemProperty;

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
.feature(FeatureFlag.DOC_VALUES_SKIPPER)
2928
.build();
3029

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
.feature(FeatureFlag.DOC_VALUES_SKIPPER)
5554
.build();
5655

0 commit comments

Comments
 (0)