Skip to content

Commit 3cfa691

Browse files
authored
[8.19] Change the handling of passthrough dimenensions (elastic#127752) (elastic#127886)
* 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. * Fix backport incompatibilities
1 parent 8820e02 commit 3cfa691

File tree

9 files changed

+480
-343
lines changed

9 files changed

+480
-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,33 +17,21 @@
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

3328
import static org.elasticsearch.cluster.metadata.IndexMetadata.INDEX_DOWNSAMPLE_STATUS;
34-
import static org.elasticsearch.xpack.downsample.DataStreamLifecycleDriver.getBackingIndices;
35-
import static org.elasticsearch.xpack.downsample.DataStreamLifecycleDriver.putTSDBIndexTemplate;
3629

3730
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0, numClientNodes = 4)
38-
public class DataStreamLifecycleDownsampleDisruptionIT extends ESIntegTestCase {
31+
public class DataStreamLifecycleDownsampleDisruptionIT extends DownsamplingIntegTestCase {
3932
private static final Logger logger = LogManager.getLogger(DataStreamLifecycleDownsampleDisruptionIT.class);
4033
public static final int DOC_COUNT = 25_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));
@@ -69,8 +57,7 @@ public void testDataStreamLifecycleDownsampleRollingRestart() throws Exception {
6957
)
7058
)
7159
.buildTemplate();
72-
DataStreamLifecycleDriver.setupTSDBDataStreamAndIngestDocs(
73-
client(),
60+
setupTSDBDataStreamAndIngestDocs(
7461
dataStreamName,
7562
"1986-01-08T23:40:53.384Z",
7663
"2022-01-08T23:40:53.384Z",
@@ -81,9 +68,9 @@ public void testDataStreamLifecycleDownsampleRollingRestart() throws Exception {
8168

8269
// before we rollover we update the index template to remove the start/end time boundaries (they're there just to ease with
8370
// testing so DSL doesn't have to wait for the end_time to lapse)
84-
putTSDBIndexTemplate(client(), dataStreamName, null, null, lifecycle);
85-
client().execute(RolloverAction.INSTANCE, new RolloverRequest(dataStreamName, null)).actionGet();
86-
String sourceIndex = getBackingIndices(client(), dataStreamName).get(0);
71+
putTSDBIndexTemplate(dataStreamName, null, null, lifecycle);
72+
safeGet(client().execute(RolloverAction.INSTANCE, new RolloverRequest(dataStreamName, null)));
73+
String sourceIndex = getDataStreamBackingIndexNames(dataStreamName).get(0);
8774
final String targetIndex = "downsample-5m-" + sourceIndex;
8875

8976
/**

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
@@ -14,35 +14,23 @@
1414
import org.elasticsearch.cluster.metadata.DataStreamLifecycle;
1515
import org.elasticsearch.common.settings.Settings;
1616
import org.elasticsearch.core.TimeValue;
17-
import org.elasticsearch.datastreams.DataStreamsPlugin;
1817
import org.elasticsearch.datastreams.lifecycle.DataStreamLifecycleService;
19-
import org.elasticsearch.plugins.Plugin;
2018
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval;
21-
import org.elasticsearch.test.ESIntegTestCase;
2219
import org.elasticsearch.test.junit.annotations.TestLogging;
23-
import org.elasticsearch.xpack.aggregatemetric.AggregateMetricMapperPlugin;
24-
import org.elasticsearch.xpack.core.LocalStateCompositeXPackPlugin;
2520

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

3226
import static org.elasticsearch.cluster.metadata.ClusterChangedEventUtils.indicesCreated;
3327
import static org.elasticsearch.cluster.metadata.DataStreamTestHelper.backingIndexEqualTo;
34-
import static org.elasticsearch.xpack.downsample.DataStreamLifecycleDriver.getBackingIndices;
35-
import static org.elasticsearch.xpack.downsample.DataStreamLifecycleDriver.putTSDBIndexTemplate;
28+
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
3629
import static org.hamcrest.Matchers.is;
3730

38-
public class DataStreamLifecycleDownsampleIT extends ESIntegTestCase {
31+
public class DataStreamLifecycleDownsampleIT extends DownsamplingIntegTestCase {
3932
public static final int DOC_COUNT = 50_000;
4033

41-
@Override
42-
protected Collection<Class<? extends Plugin>> nodePlugins() {
43-
return List.of(DataStreamsPlugin.class, LocalStateCompositeXPackPlugin.class, Downsample.class, AggregateMetricMapperPlugin.class);
44-
}
45-
4634
@Override
4735
protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
4836
Settings.Builder settings = Settings.builder().put(super.nodeSettings(nodeOrdinal, otherSettings));
@@ -69,8 +57,7 @@ public void testDownsampling() throws Exception {
6957
)
7058
.buildTemplate();
7159

72-
DataStreamLifecycleDriver.setupTSDBDataStreamAndIngestDocs(
73-
client(),
60+
setupTSDBDataStreamAndIngestDocs(
7461
dataStreamName,
7562
"1986-01-08T23:40:53.384Z",
7663
"2022-01-08T23:40:53.384Z",
@@ -79,7 +66,7 @@ public void testDownsampling() throws Exception {
7966
"1990-09-09T18:00:00"
8067
);
8168

82-
List<String> backingIndices = getBackingIndices(client(), dataStreamName);
69+
List<String> backingIndices = getDataStreamBackingIndexNames(dataStreamName);
8370
String firstGenerationBackingIndex = backingIndices.get(0);
8471
String oneSecondDownsampleIndex = "downsample-5m-" + firstGenerationBackingIndex;
8572
String tenSecondsDownsampleIndex = "downsample-10m-" + firstGenerationBackingIndex;
@@ -96,7 +83,7 @@ public void testDownsampling() throws Exception {
9683
});
9784
// before we rollover we update the index template to remove the start/end time boundaries (they're there just to ease with
9885
// testing so DSL doesn't have to wait for the end_time to lapse)
99-
putTSDBIndexTemplate(client(), dataStreamName, null, null, lifecycle);
86+
putTSDBIndexTemplate(dataStreamName, null, null, lifecycle);
10087

10188
client().execute(RolloverAction.INSTANCE, new RolloverRequest(dataStreamName, null)).actionGet();
10289

@@ -112,7 +99,7 @@ public void testDownsampling() throws Exception {
11299
}, 30, TimeUnit.SECONDS);
113100

114101
assertBusy(() -> {
115-
List<String> dsBackingIndices = getBackingIndices(client(), dataStreamName);
102+
List<String> dsBackingIndices = getDataStreamBackingIndexNames(dataStreamName);
116103

117104
assertThat(dsBackingIndices.size(), is(2));
118105
String writeIndex = dsBackingIndices.get(1);
@@ -143,8 +130,7 @@ public void testDownsamplingOnlyExecutesTheLastMatchingRound() throws Exception
143130
)
144131
)
145132
.buildTemplate();
146-
DataStreamLifecycleDriver.setupTSDBDataStreamAndIngestDocs(
147-
client(),
133+
setupTSDBDataStreamAndIngestDocs(
148134
dataStreamName,
149135
"1986-01-08T23:40:53.384Z",
150136
"2022-01-08T23:40:53.384Z",
@@ -153,7 +139,7 @@ public void testDownsamplingOnlyExecutesTheLastMatchingRound() throws Exception
153139
"1990-09-09T18:00:00"
154140
);
155141

156-
List<String> backingIndices = getBackingIndices(client(), dataStreamName);
142+
List<String> backingIndices = getDataStreamBackingIndexNames(dataStreamName);
157143
String firstGenerationBackingIndex = backingIndices.get(0);
158144
String oneSecondDownsampleIndex = "downsample-5m-" + firstGenerationBackingIndex;
159145
String tenSecondsDownsampleIndex = "downsample-10m-" + firstGenerationBackingIndex;
@@ -170,7 +156,7 @@ public void testDownsamplingOnlyExecutesTheLastMatchingRound() throws Exception
170156
});
171157
// before we rollover we update the index template to remove the start/end time boundaries (they're there just to ease with
172158
// testing so DSL doesn't have to wait for the end_time to lapse)
173-
putTSDBIndexTemplate(client(), dataStreamName, null, null, lifecycle);
159+
putTSDBIndexTemplate(dataStreamName, null, null, lifecycle);
174160
client().execute(RolloverAction.INSTANCE, new RolloverRequest(dataStreamName, null)).actionGet();
175161

176162
assertBusy(() -> {
@@ -180,7 +166,7 @@ public void testDownsamplingOnlyExecutesTheLastMatchingRound() throws Exception
180166
}, 30, TimeUnit.SECONDS);
181167

182168
assertBusy(() -> {
183-
List<String> dsBackingIndices = getBackingIndices(client(), dataStreamName);
169+
List<String> dsBackingIndices = getDataStreamBackingIndexNames(dataStreamName);
184170

185171
assertThat(dsBackingIndices.size(), is(2));
186172
String writeIndex = dsBackingIndices.get(1);
@@ -212,8 +198,7 @@ public void testUpdateDownsampleRound() throws Exception {
212198
)
213199
.buildTemplate();
214200

215-
DataStreamLifecycleDriver.setupTSDBDataStreamAndIngestDocs(
216-
client(),
201+
setupTSDBDataStreamAndIngestDocs(
217202
dataStreamName,
218203
"1986-01-08T23:40:53.384Z",
219204
"2022-01-08T23:40:53.384Z",
@@ -222,7 +207,7 @@ public void testUpdateDownsampleRound() throws Exception {
222207
"1990-09-09T18:00:00"
223208
);
224209

225-
List<String> backingIndices = getBackingIndices(client(), dataStreamName);
210+
List<String> backingIndices = getDataStreamBackingIndexNames(dataStreamName);
226211
String firstGenerationBackingIndex = backingIndices.get(0);
227212
String oneSecondDownsampleIndex = "downsample-5m-" + firstGenerationBackingIndex;
228213
String tenSecondsDownsampleIndex = "downsample-10m-" + firstGenerationBackingIndex;
@@ -239,8 +224,8 @@ public void testUpdateDownsampleRound() throws Exception {
239224
});
240225
// before we rollover we update the index template to remove the start/end time boundaries (they're there just to ease with
241226
// testing so DSL doesn't have to wait for the end_time to lapse)
242-
putTSDBIndexTemplate(client(), dataStreamName, null, null, lifecycle);
243-
client().execute(RolloverAction.INSTANCE, new RolloverRequest(dataStreamName, null)).actionGet();
227+
putTSDBIndexTemplate(dataStreamName, null, null, lifecycle);
228+
safeGet(client().execute(RolloverAction.INSTANCE, new RolloverRequest(dataStreamName, null)));
244229

245230
assertBusy(() -> {
246231
assertThat(witnessedDownsamplingIndices.size(), is(1));
@@ -249,7 +234,7 @@ public void testUpdateDownsampleRound() throws Exception {
249234
}, 30, TimeUnit.SECONDS);
250235

251236
assertBusy(() -> {
252-
List<String> dsBackingIndices = getBackingIndices(client(), dataStreamName);
237+
List<String> dsBackingIndices = getDataStreamBackingIndexNames(dataStreamName);
253238
assertThat(dsBackingIndices.size(), is(2));
254239
String writeIndex = dsBackingIndices.get(1);
255240
assertThat(writeIndex, backingIndexEqualTo(dataStreamName, 2));
@@ -258,7 +243,7 @@ public void testUpdateDownsampleRound() throws Exception {
258243

259244
// update the lifecycle so that it only has one round, for the same `after` parameter as before, but a different interval
260245
// the different interval should yield a different downsample index name so we expect the data stream lifecycle to get the previous
261-
// `10s` interval downsample index, downsample it to `30s` and replace it in the data stream instead of the `10s` one.
246+
// `10s` interval downsample index, downsample it to `20m` and replace it in the data stream instead of the `10s` one.
262247
DataStreamLifecycle updatedLifecycle = DataStreamLifecycle.dataLifecycleBuilder()
263248
.downsampling(
264249
List.of(
@@ -269,14 +254,15 @@ public void testUpdateDownsampleRound() throws Exception {
269254
)
270255
)
271256
.build();
272-
273-
client().execute(
274-
PutDataStreamLifecycleAction.INSTANCE,
275-
new PutDataStreamLifecycleAction.Request(
276-
TEST_REQUEST_TIMEOUT,
277-
TEST_REQUEST_TIMEOUT,
278-
new String[] { dataStreamName },
279-
updatedLifecycle
257+
assertAcked(
258+
client().execute(
259+
PutDataStreamLifecycleAction.INSTANCE,
260+
new PutDataStreamLifecycleAction.Request(
261+
TEST_REQUEST_TIMEOUT,
262+
TEST_REQUEST_TIMEOUT,
263+
new String[] { dataStreamName },
264+
updatedLifecycle
265+
)
280266
)
281267
);
282268

@@ -285,7 +271,7 @@ public void testUpdateDownsampleRound() throws Exception {
285271
assertBusy(() -> {
286272
assertThat(indexExists(tenSecondsDownsampleIndex), is(false));
287273

288-
List<String> dsBackingIndices = getBackingIndices(client(), dataStreamName);
274+
List<String> dsBackingIndices = getDataStreamBackingIndexNames(dataStreamName);
289275
assertThat(dsBackingIndices.size(), is(2));
290276
String writeIndex = dsBackingIndices.get(1);
291277
assertThat(writeIndex, backingIndexEqualTo(dataStreamName, 2));

0 commit comments

Comments
 (0)