Skip to content

Commit 552da22

Browse files
authored
Remove index.dimensions feature flag (#135402)
1 parent 5e148a9 commit 552da22

File tree

6 files changed

+19
-50
lines changed

6 files changed

+19
-50
lines changed

docs/changelog/135402.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 135402
2+
summary: Improve TSDB ingestion by hashing dimensions only once, using a new auto-populeted `index.dimensions` private index setting
3+
area: TSDB
4+
type: enhancement
5+
issues: []

modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/TSDBIndexingIT.java

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
import java.util.Map;
6868
import java.util.concurrent.CountDownLatch;
6969

70-
import static org.elasticsearch.datastreams.DataStreamIndexSettingsProvider.INDEX_DIMENSIONS_TSID_OPTIMIZATION_FEATURE_FLAG;
7170
import static org.elasticsearch.test.MapMatcher.assertMap;
7271
import static org.elasticsearch.test.MapMatcher.matchesMap;
7372
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
@@ -333,10 +332,7 @@ public void testTsdbTemplatesNoKeywordFieldType() throws Exception {
333332
new Template(
334333
Settings.builder()
335334
.put("index.mode", "time_series")
336-
.put(
337-
"index.routing_path",
338-
randomBoolean() && INDEX_DIMENSIONS_TSID_OPTIMIZATION_FEATURE_FLAG ? null : "metricset"
339-
)
335+
.put("index.routing_path", randomBoolean() ? null : "metricset")
340336
.build(),
341337
new CompressedXContent(mappingTemplate),
342338
null
@@ -666,13 +662,8 @@ public void testAddDimensionToMapping() throws Exception {
666662
"my-ds"
667663
);
668664
assertAcked(client().execute(CreateDataStreamAction.INSTANCE, createDsRequest));
669-
if (INDEX_DIMENSIONS_TSID_OPTIMIZATION_FEATURE_FLAG) {
670-
assertThat(getSetting(dataStreamName, IndexMetadata.INDEX_DIMENSIONS), equalTo(List.of("metricset")));
671-
assertThat(getSetting(dataStreamName, IndexMetadata.INDEX_ROUTING_PATH), empty());
672-
} else {
673-
assertThat(getSetting(dataStreamName, IndexMetadata.INDEX_DIMENSIONS), empty());
674-
assertThat(getSetting(dataStreamName, IndexMetadata.INDEX_ROUTING_PATH), equalTo(List.of("metricset")));
675-
}
665+
assertThat(getSetting(dataStreamName, IndexMetadata.INDEX_DIMENSIONS), equalTo(List.of("metricset")));
666+
assertThat(getSetting(dataStreamName, IndexMetadata.INDEX_ROUTING_PATH), empty());
676667

677668
// put mapping with k8s.pod.uid as another time series dimension
678669
var putMappingRequest = new PutMappingRequest(dataStreamName).source("""
@@ -686,13 +677,8 @@ public void testAddDimensionToMapping() throws Exception {
686677
}
687678
""", XContentType.JSON);
688679
assertAcked(client().execute(TransportPutMappingAction.TYPE, putMappingRequest).actionGet());
689-
if (INDEX_DIMENSIONS_TSID_OPTIMIZATION_FEATURE_FLAG) {
690-
assertThat(getSetting(dataStreamName, IndexMetadata.INDEX_DIMENSIONS), containsInAnyOrder("metricset", "k8s.pod.name"));
691-
assertThat(getSetting(dataStreamName, IndexMetadata.INDEX_ROUTING_PATH), empty());
692-
} else {
693-
assertThat(getSetting(dataStreamName, IndexMetadata.INDEX_DIMENSIONS), empty());
694-
assertThat(getSetting(dataStreamName, IndexMetadata.INDEX_ROUTING_PATH), equalTo(List.of("metricset")));
695-
}
680+
assertThat(getSetting(dataStreamName, IndexMetadata.INDEX_DIMENSIONS), containsInAnyOrder("metricset", "k8s.pod.name"));
681+
assertThat(getSetting(dataStreamName, IndexMetadata.INDEX_ROUTING_PATH), empty());
696682

697683
// put dynamic template defining time series dimensions
698684
// we don't support index.dimensions in that case

modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/TSDBPassthroughIndexingIT.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
import java.util.List;
4545
import java.util.Map;
4646

47-
import static org.elasticsearch.datastreams.DataStreamIndexSettingsProvider.INDEX_DIMENSIONS_TSID_OPTIMIZATION_FEATURE_FLAG;
4847
import static org.elasticsearch.test.MapMatcher.assertMap;
4948
import static org.elasticsearch.test.MapMatcher.matchesMap;
5049
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
@@ -186,13 +185,8 @@ public void testIndexingGettingAndSearching() throws Exception {
186185

187186
// validate index:
188187
var getIndexResponse = client().admin().indices().getIndex(new GetIndexRequest(TEST_REQUEST_TIMEOUT).indices(index)).actionGet();
189-
if (INDEX_DIMENSIONS_TSID_OPTIMIZATION_FEATURE_FLAG) {
190-
assertThat(getIndexResponse.getSettings().get(index).get("index.dimensions"), equalTo("[attributes.*]"));
191-
assertThat(getIndexResponse.getSettings().get(index).get("index.routing_path"), nullValue());
192-
} else {
193-
assertThat(getIndexResponse.getSettings().get(index).get("index.dimensions"), nullValue());
194-
assertThat(getIndexResponse.getSettings().get(index).get("index.routing_path"), equalTo("[attributes.*]"));
195-
}
188+
assertThat(getIndexResponse.getSettings().get(index).get("index.dimensions"), equalTo("[attributes.*]"));
189+
assertThat(getIndexResponse.getSettings().get(index).get("index.routing_path"), nullValue());
196190
// validate mapping
197191
var mapping = getIndexResponse.mappings().get(index).getSourceAsMap();
198192
assertMap(

modules/data-streams/src/main/java/org/elasticsearch/datastreams/DataStreamIndexSettingsProvider.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import org.elasticsearch.common.regex.Regex;
1717
import org.elasticsearch.common.settings.Settings;
1818
import org.elasticsearch.common.time.DateFormatter;
19-
import org.elasticsearch.common.util.FeatureFlag;
2019
import org.elasticsearch.core.CheckedFunction;
2120
import org.elasticsearch.core.Nullable;
2221
import org.elasticsearch.core.TimeValue;
@@ -50,8 +49,6 @@
5049
*/
5150
public class DataStreamIndexSettingsProvider implements IndexSettingProvider {
5251

53-
public static final boolean INDEX_DIMENSIONS_TSID_OPTIMIZATION_FEATURE_FLAG = new FeatureFlag("index_dimensions_tsid_optimization")
54-
.isEnabled();
5552
static final DateFormatter FORMATTER = DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER;
5653

5754
private final CheckedFunction<IndexMetadata, MapperService, IOException> mapperServiceFactory;
@@ -133,9 +130,7 @@ public void provideAdditionalSettings(
133130
dimensions
134131
);
135132
if (dimensions.isEmpty() == false) {
136-
if (matchesAllDimensions
137-
&& INDEX_DIMENSIONS_TSID_OPTIMIZATION_FEATURE_FLAG
138-
&& indexVersion.onOrAfter(IndexVersions.TSID_CREATED_DURING_ROUTING)) {
133+
if (matchesAllDimensions && indexVersion.onOrAfter(IndexVersions.TSID_CREATED_DURING_ROUTING)) {
139134
// Only set index.dimensions if the paths in the dimensions list match all potential dimension fields.
140135
// This is not the case e.g. if a dynamic template matches by match_mapping_type instead of path_match
141136
additionalSettings.putList(INDEX_DIMENSIONS.getKey(), dimensions);

modules/data-streams/src/test/java/org/elasticsearch/datastreams/DataStreamIndexSettingsProviderTests.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import static org.elasticsearch.cluster.metadata.DataStreamTestHelper.newInstance;
4040
import static org.elasticsearch.common.settings.Settings.builder;
4141
import static org.elasticsearch.datastreams.DataStreamIndexSettingsProvider.FORMATTER;
42-
import static org.elasticsearch.datastreams.DataStreamIndexSettingsProvider.INDEX_DIMENSIONS_TSID_OPTIMIZATION_FEATURE_FLAG;
4342
import static org.hamcrest.Matchers.containsInAnyOrder;
4443
import static org.hamcrest.Matchers.empty;
4544
import static org.hamcrest.Matchers.equalTo;
@@ -61,8 +60,7 @@ public void setup() {
6160
indexVersion = randomBoolean()
6261
? IndexVersionUtils.randomPreviousCompatibleVersion(random(), IndexVersions.TSID_CREATED_DURING_ROUTING)
6362
: IndexVersionUtils.randomVersionBetween(random(), IndexVersions.TSID_CREATED_DURING_ROUTING, IndexVersion.current());
64-
indexDimensionsTsidOptimizationEnabled = INDEX_DIMENSIONS_TSID_OPTIMIZATION_FEATURE_FLAG
65-
&& indexVersion.onOrAfter(IndexVersions.TSID_CREATED_DURING_ROUTING);
63+
indexDimensionsTsidOptimizationEnabled = indexVersion.onOrAfter(IndexVersions.TSID_CREATED_DURING_ROUTING);
6664
}
6765

6866
public void testGetAdditionalIndexSettings() throws Exception {

x-pack/plugin/downsample/src/test/java/org/elasticsearch/xpack/downsample/DownsampleDataStreamTests.java

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
import java.util.concurrent.TimeUnit;
6565

6666
import static org.elasticsearch.cluster.metadata.MetadataIndexTemplateService.DEFAULT_TIMESTAMP_FIELD;
67-
import static org.elasticsearch.datastreams.DataStreamIndexSettingsProvider.INDEX_DIMENSIONS_TSID_OPTIMIZATION_FEATURE_FLAG;
6867
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertResponse;
6968
import static org.hamcrest.Matchers.containsInAnyOrder;
7069
import static org.hamcrest.Matchers.empty;
@@ -200,19 +199,11 @@ public void testDataStreamDownsample() throws ExecutionException, InterruptedExc
200199
assertThat(setting.hasValue(IndexMetadata.INDEX_DIMENSIONS.getKey()), equalTo(false));
201200
assertThat(setting.getAsList(IndexMetadata.INDEX_ROUTING_PATH.getKey()), containsInAnyOrder("routing_field"));
202201
} else {
203-
if (INDEX_DIMENSIONS_TSID_OPTIMIZATION_FEATURE_FLAG) {
204-
assertThat(
205-
setting.getAsList(IndexMetadata.INDEX_DIMENSIONS.getKey()),
206-
containsInAnyOrder("routing_field", "dimension")
207-
);
208-
assertThat(setting.getAsList(IndexMetadata.INDEX_ROUTING_PATH.getKey()), empty());
209-
} else {
210-
assertThat(setting.getAsList(IndexMetadata.INDEX_DIMENSIONS.getKey()), empty());
211-
assertThat(
212-
setting.getAsList(IndexMetadata.INDEX_ROUTING_PATH.getKey()),
213-
containsInAnyOrder("routing_field", "dimension")
214-
);
215-
}
202+
assertThat(
203+
setting.getAsList(IndexMetadata.INDEX_DIMENSIONS.getKey()),
204+
containsInAnyOrder("routing_field", "dimension")
205+
);
206+
assertThat(setting.getAsList(IndexMetadata.INDEX_ROUTING_PATH.getKey()), empty());
216207
}
217208
});
218209
});

0 commit comments

Comments
 (0)