Skip to content

Commit d7c769e

Browse files
committed
Change the handling of passthrough dimenensions (elastic#127752)
When downsampling an index that has a mapping with passthrough dimensions the downsampling process identifies the wrapper object as a dimension and it fails when it tried to retrieve the type. We did some prework to establish a shared framework in the internalClusterTest. For now it only includes setting up time series data stream helpers and a limited assertion helper for dimensions and metrics. This allows us to setup an internalClusterTest that captures this issue during downsampling in elastic#125156. To fix this we refine the check that determines if a field is dimension, to skip wrapper field. Fixes elastic#125156.
1 parent 3d366e6 commit d7c769e

File tree

9 files changed

+488
-343
lines changed

9 files changed

+488
-343
lines changed

docs/changelog/127752.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 127752
2+
summary: Downsampling does not consider passthrough fields as dimensions
3+
area: Downsampling
4+
type: bug
5+
issues:
6+
- 125156

x-pack/plugin/downsample/src/internalClusterTest/java/org/elasticsearch/xpack/downsample/DataStreamLifecycleDownsampleDisruptionIT.java

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,22 @@
1717
import org.elasticsearch.cluster.service.ClusterService;
1818
import org.elasticsearch.common.settings.Settings;
1919
import org.elasticsearch.core.TimeValue;
20-
import org.elasticsearch.datastreams.DataStreamsPlugin;
2120
import org.elasticsearch.datastreams.lifecycle.DataStreamLifecycleService;
22-
import org.elasticsearch.plugins.Plugin;
2321
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval;
2422
import org.elasticsearch.test.ClusterServiceUtils;
2523
import org.elasticsearch.test.ESIntegTestCase;
2624
import org.elasticsearch.test.InternalTestCluster;
27-
import org.elasticsearch.xpack.aggregatemetric.AggregateMetricMapperPlugin;
28-
import org.elasticsearch.xpack.core.LocalStateCompositeXPackPlugin;
2925

30-
import java.util.Collection;
3126
import java.util.List;
3227
import java.util.concurrent.TimeUnit;
3328

3429
import static org.elasticsearch.cluster.metadata.IndexMetadata.INDEX_DOWNSAMPLE_STATUS;
35-
import static org.elasticsearch.xpack.downsample.DataStreamLifecycleDriver.getBackingIndices;
36-
import static org.elasticsearch.xpack.downsample.DataStreamLifecycleDriver.putTSDBIndexTemplate;
3730

3831
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0, numClientNodes = 4)
39-
public class DataStreamLifecycleDownsampleDisruptionIT extends ESIntegTestCase {
32+
public class DataStreamLifecycleDownsampleDisruptionIT extends DownsamplingIntegTestCase {
4033
private static final Logger logger = LogManager.getLogger(DataStreamLifecycleDownsampleDisruptionIT.class);
4134
public static final int DOC_COUNT = 25_000;
4235

43-
@Override
44-
protected Collection<Class<? extends Plugin>> nodePlugins() {
45-
return List.of(DataStreamsPlugin.class, LocalStateCompositeXPackPlugin.class, Downsample.class, AggregateMetricMapperPlugin.class);
46-
}
47-
4836
@Override
4937
protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
5038
Settings.Builder settings = Settings.builder().put(super.nodeSettings(nodeOrdinal, otherSettings));
@@ -72,8 +60,7 @@ public void testDataStreamLifecycleDownsampleRollingRestart() throws Exception {
7260
)
7361
)
7462
.build();
75-
DataStreamLifecycleDriver.setupTSDBDataStreamAndIngestDocs(
76-
client(),
63+
setupTSDBDataStreamAndIngestDocs(
7764
dataStreamName,
7865
"1986-01-08T23:40:53.384Z",
7966
"2022-01-08T23:40:53.384Z",
@@ -84,9 +71,9 @@ public void testDataStreamLifecycleDownsampleRollingRestart() throws Exception {
8471

8572
// before we rollover we update the index template to remove the start/end time boundaries (they're there just to ease with
8673
// testing so DSL doesn't have to wait for the end_time to lapse)
87-
putTSDBIndexTemplate(client(), dataStreamName, null, null, lifecycle);
88-
client().execute(RolloverAction.INSTANCE, new RolloverRequest(dataStreamName, null)).actionGet();
89-
String sourceIndex = getBackingIndices(client(), dataStreamName).get(0);
74+
putTSDBIndexTemplate(dataStreamName, null, null, lifecycle);
75+
safeGet(client().execute(RolloverAction.INSTANCE, new RolloverRequest(dataStreamName, null)));
76+
String sourceIndex = getDataStreamBackingIndexNames(dataStreamName).get(0);
9077
final String targetIndex = "downsample-5m-" + sourceIndex;
9178

9279
/**

x-pack/plugin/downsample/src/internalClusterTest/java/org/elasticsearch/xpack/downsample/DataStreamLifecycleDownsampleIT.java

Lines changed: 26 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,23 @@
1515
import org.elasticsearch.cluster.metadata.DataStreamLifecycle.Downsampling;
1616
import org.elasticsearch.common.settings.Settings;
1717
import org.elasticsearch.core.TimeValue;
18-
import org.elasticsearch.datastreams.DataStreamsPlugin;
1918
import org.elasticsearch.datastreams.lifecycle.DataStreamLifecycleService;
20-
import org.elasticsearch.plugins.Plugin;
2119
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval;
22-
import org.elasticsearch.test.ESIntegTestCase;
2320
import org.elasticsearch.test.junit.annotations.TestLogging;
24-
import org.elasticsearch.xpack.aggregatemetric.AggregateMetricMapperPlugin;
25-
import org.elasticsearch.xpack.core.LocalStateCompositeXPackPlugin;
2621

27-
import java.util.Collection;
2822
import java.util.HashSet;
2923
import java.util.List;
3024
import java.util.Set;
3125
import java.util.concurrent.TimeUnit;
3226

3327
import static org.elasticsearch.cluster.metadata.ClusterChangedEventUtils.indicesCreated;
3428
import static org.elasticsearch.cluster.metadata.DataStreamTestHelper.backingIndexEqualTo;
35-
import static org.elasticsearch.xpack.downsample.DataStreamLifecycleDriver.getBackingIndices;
36-
import static org.elasticsearch.xpack.downsample.DataStreamLifecycleDriver.putTSDBIndexTemplate;
29+
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
3730
import static org.hamcrest.Matchers.is;
3831

39-
public class DataStreamLifecycleDownsampleIT extends ESIntegTestCase {
32+
public class DataStreamLifecycleDownsampleIT extends DownsamplingIntegTestCase {
4033
public static final int DOC_COUNT = 50_000;
4134

42-
@Override
43-
protected Collection<Class<? extends Plugin>> nodePlugins() {
44-
return List.of(DataStreamsPlugin.class, LocalStateCompositeXPackPlugin.class, Downsample.class, AggregateMetricMapperPlugin.class);
45-
}
46-
4735
@Override
4836
protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
4937
Settings.Builder settings = Settings.builder().put(super.nodeSettings(nodeOrdinal, otherSettings));
@@ -66,8 +54,7 @@ public void testDownsampling() throws Exception {
6654
)
6755
.build();
6856

69-
DataStreamLifecycleDriver.setupTSDBDataStreamAndIngestDocs(
70-
client(),
57+
setupTSDBDataStreamAndIngestDocs(
7158
dataStreamName,
7259
"1986-01-08T23:40:53.384Z",
7360
"2022-01-08T23:40:53.384Z",
@@ -76,7 +63,7 @@ public void testDownsampling() throws Exception {
7663
"1990-09-09T18:00:00"
7764
);
7865

79-
List<String> backingIndices = getBackingIndices(client(), dataStreamName);
66+
List<String> backingIndices = getDataStreamBackingIndexNames(dataStreamName);
8067
String firstGenerationBackingIndex = backingIndices.get(0);
8168
String oneSecondDownsampleIndex = "downsample-5m-" + firstGenerationBackingIndex;
8269
String tenSecondsDownsampleIndex = "downsample-10m-" + firstGenerationBackingIndex;
@@ -93,7 +80,7 @@ public void testDownsampling() throws Exception {
9380
});
9481
// before we rollover we update the index template to remove the start/end time boundaries (they're there just to ease with
9582
// testing so DSL doesn't have to wait for the end_time to lapse)
96-
putTSDBIndexTemplate(client(), dataStreamName, null, null, lifecycle);
83+
putTSDBIndexTemplate(dataStreamName, null, null, lifecycle);
9784

9885
client().execute(RolloverAction.INSTANCE, new RolloverRequest(dataStreamName, null)).actionGet();
9986

@@ -109,7 +96,7 @@ public void testDownsampling() throws Exception {
10996
}, 30, TimeUnit.SECONDS);
11097

11198
assertBusy(() -> {
112-
List<String> dsBackingIndices = getBackingIndices(client(), dataStreamName);
99+
List<String> dsBackingIndices = getDataStreamBackingIndexNames(dataStreamName);
113100

114101
assertThat(dsBackingIndices.size(), is(2));
115102
String writeIndex = dsBackingIndices.get(1);
@@ -136,8 +123,7 @@ public void testDownsamplingOnlyExecutesTheLastMatchingRound() throws Exception
136123
)
137124
)
138125
.build();
139-
DataStreamLifecycleDriver.setupTSDBDataStreamAndIngestDocs(
140-
client(),
126+
setupTSDBDataStreamAndIngestDocs(
141127
dataStreamName,
142128
"1986-01-08T23:40:53.384Z",
143129
"2022-01-08T23:40:53.384Z",
@@ -146,7 +132,7 @@ public void testDownsamplingOnlyExecutesTheLastMatchingRound() throws Exception
146132
"1990-09-09T18:00:00"
147133
);
148134

149-
List<String> backingIndices = getBackingIndices(client(), dataStreamName);
135+
List<String> backingIndices = getDataStreamBackingIndexNames(dataStreamName);
150136
String firstGenerationBackingIndex = backingIndices.get(0);
151137
String oneSecondDownsampleIndex = "downsample-5m-" + firstGenerationBackingIndex;
152138
String tenSecondsDownsampleIndex = "downsample-10m-" + firstGenerationBackingIndex;
@@ -163,7 +149,7 @@ public void testDownsamplingOnlyExecutesTheLastMatchingRound() throws Exception
163149
});
164150
// before we rollover we update the index template to remove the start/end time boundaries (they're there just to ease with
165151
// testing so DSL doesn't have to wait for the end_time to lapse)
166-
putTSDBIndexTemplate(client(), dataStreamName, null, null, lifecycle);
152+
putTSDBIndexTemplate(dataStreamName, null, null, lifecycle);
167153
client().execute(RolloverAction.INSTANCE, new RolloverRequest(dataStreamName, null)).actionGet();
168154

169155
assertBusy(() -> {
@@ -173,7 +159,7 @@ public void testDownsamplingOnlyExecutesTheLastMatchingRound() throws Exception
173159
}, 30, TimeUnit.SECONDS);
174160

175161
assertBusy(() -> {
176-
List<String> dsBackingIndices = getBackingIndices(client(), dataStreamName);
162+
List<String> dsBackingIndices = getDataStreamBackingIndexNames(dataStreamName);
177163

178164
assertThat(dsBackingIndices.size(), is(2));
179165
String writeIndex = dsBackingIndices.get(1);
@@ -201,8 +187,7 @@ public void testUpdateDownsampleRound() throws Exception {
201187
)
202188
.build();
203189

204-
DataStreamLifecycleDriver.setupTSDBDataStreamAndIngestDocs(
205-
client(),
190+
setupTSDBDataStreamAndIngestDocs(
206191
dataStreamName,
207192
"1986-01-08T23:40:53.384Z",
208193
"2022-01-08T23:40:53.384Z",
@@ -211,7 +196,7 @@ public void testUpdateDownsampleRound() throws Exception {
211196
"1990-09-09T18:00:00"
212197
);
213198

214-
List<String> backingIndices = getBackingIndices(client(), dataStreamName);
199+
List<String> backingIndices = getDataStreamBackingIndexNames(dataStreamName);
215200
String firstGenerationBackingIndex = backingIndices.get(0);
216201
String oneSecondDownsampleIndex = "downsample-5m-" + firstGenerationBackingIndex;
217202
String tenSecondsDownsampleIndex = "downsample-10m-" + firstGenerationBackingIndex;
@@ -228,8 +213,8 @@ public void testUpdateDownsampleRound() throws Exception {
228213
});
229214
// before we rollover we update the index template to remove the start/end time boundaries (they're there just to ease with
230215
// testing so DSL doesn't have to wait for the end_time to lapse)
231-
putTSDBIndexTemplate(client(), dataStreamName, null, null, lifecycle);
232-
client().execute(RolloverAction.INSTANCE, new RolloverRequest(dataStreamName, null)).actionGet();
216+
putTSDBIndexTemplate(dataStreamName, null, null, lifecycle);
217+
safeGet(client().execute(RolloverAction.INSTANCE, new RolloverRequest(dataStreamName, null)));
233218

234219
assertBusy(() -> {
235220
assertThat(witnessedDownsamplingIndices.size(), is(1));
@@ -238,7 +223,7 @@ public void testUpdateDownsampleRound() throws Exception {
238223
}, 30, TimeUnit.SECONDS);
239224

240225
assertBusy(() -> {
241-
List<String> dsBackingIndices = getBackingIndices(client(), dataStreamName);
226+
List<String> dsBackingIndices = getDataStreamBackingIndexNames(dataStreamName);
242227
assertThat(dsBackingIndices.size(), is(2));
243228
String writeIndex = dsBackingIndices.get(1);
244229
assertThat(writeIndex, backingIndexEqualTo(dataStreamName, 2));
@@ -247,22 +232,23 @@ public void testUpdateDownsampleRound() throws Exception {
247232

248233
// update the lifecycle so that it only has one round, for the same `after` parameter as before, but a different interval
249234
// the different interval should yield a different downsample index name so we expect the data stream lifecycle to get the previous
250-
// `10s` interval downsample index, downsample it to `30s` and replace it in the data stream instead of the `10s` one.
235+
// `10s` interval downsample index, downsample it to `20m` and replace it in the data stream instead of the `10s` one.
251236
DataStreamLifecycle updatedLifecycle = DataStreamLifecycle.newBuilder()
252237
.downsampling(
253238
new Downsampling(
254239
List.of(new Downsampling.Round(TimeValue.timeValueMillis(10), new DownsampleConfig(new DateHistogramInterval("20m"))))
255240
)
256241
)
257242
.build();
258-
259-
client().execute(
260-
PutDataStreamLifecycleAction.INSTANCE,
261-
new PutDataStreamLifecycleAction.Request(
262-
TEST_REQUEST_TIMEOUT,
263-
TEST_REQUEST_TIMEOUT,
264-
new String[] { dataStreamName },
265-
updatedLifecycle
243+
assertAcked(
244+
client().execute(
245+
PutDataStreamLifecycleAction.INSTANCE,
246+
new PutDataStreamLifecycleAction.Request(
247+
TEST_REQUEST_TIMEOUT,
248+
TEST_REQUEST_TIMEOUT,
249+
new String[] { dataStreamName },
250+
updatedLifecycle
251+
)
266252
)
267253
);
268254

@@ -271,7 +257,7 @@ public void testUpdateDownsampleRound() throws Exception {
271257
assertBusy(() -> {
272258
assertThat(indexExists(tenSecondsDownsampleIndex), is(false));
273259

274-
List<String> dsBackingIndices = getBackingIndices(client(), dataStreamName);
260+
List<String> dsBackingIndices = getDataStreamBackingIndexNames(dataStreamName);
275261
assertThat(dsBackingIndices.size(), is(2));
276262
String writeIndex = dsBackingIndices.get(1);
277263
assertThat(writeIndex, backingIndexEqualTo(dataStreamName, 2));

0 commit comments

Comments
 (0)