Skip to content

Commit 1bc60ac

Browse files
authored
Revert "Deprecate _source.mode in mappings (#117106)" (#117151)
This reverts #117106. Bwc tests fail, because older nodes are killed with the following error: ``` [2024-11-20T10:54:58,600][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [v8.17.0-0] fatal error in thread [elasticsearch[v8.17.0-0 ][clusterApplierService#updateTask][T#1]], exiting java.lang.AssertionError: provided source [{"_doc":{"_data_stream_timestamp":{"enabled":true},"_source":{},"properties":{"@timestamp":{"type":"date"},"k8s":{"properties":{"pod":{"properties":{"ip":{"type":"ip"},"name":{"type":"keyword"},"network":{"properties":{"rx":{"type":"long"},"tx":{"type":"long"}}},"uid":{"type":"keyword","time_series_dimension":true}}}}},"metricset":{"type":"keyword","time_series_dimension":true}}}}] differs from mapping [{"_doc":{"_data_stream_timestamp":{"enabled":true},"_source":{"mode":"synthetic"},"properties":{"@timestamp":{"type":"date"},"k8s":{"properties":{"pod":{"properties":{"ip":{"type":"ip"},"name":{"type":"keyword"},"network":{"properties":{"rx":{"type":"long"},"tx":{"type":"long"}}},"uid":{"type":"keyword","time_series_dimension":true}}}}},"metricset":{"type":"keyword","time_series_dimension":true}}}}] at [email protected]/org.elasticsearch.index.mapper.DocumentMapper.<init>(DocumentMapper.java:66) at [email protected]/org.elasticsearch.index.mapper.MapperService.newDocumentMapper(MapperService.java:588) at [email protected]/org.elasticsearch.index.mapper.MapperService.updateMapping(MapperService.java:346) at [email protected]/org.elasticsearch.index.IndexService.updateMapping(IndexService.java:840) at [email protected]/org.elasticsearch.indices.cluster.IndicesClusterStateService.createIndicesAndUpdateShards(IndicesClusterStateService.java:583) at [email protected]/org.elasticsearch.indices.cluster.IndicesClusterStateService.doApplyClusterState(IndicesClusterStateService.java:306) at [email protected]/org.elasticsearch.indices.cluster.IndicesClusterStateService.applyClusterState(IndicesClusterStateService.java:260) at [email protected]/org.elasticsearch.cluster.service.ClusterApplierService.callClusterStateAppliers(ClusterApplierService.java:544) at [email protected]/org.elasticsearch.cluster.service.ClusterApplierService.callClusterStateAppliers(ClusterApplierService.java:530) at [email protected]/org.elasticsearch.cluster.service.ClusterApplierService.applyChanges(ClusterApplierService.java:503) at [email protected]/org.elasticsearch.cluster.service.ClusterApplierService.runTask(ClusterApplierService.java:432) at [email protected]/org.elasticsearch.cluster.service.ClusterApplierService$UpdateTask.run(ClusterApplierService.java:157) at [email protected]/org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:956) at [email protected]/org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.runAndClean(PrioritizedEsThreadPoolExecutor.java:218) at [email protected]/org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:184) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) at java.base/java.lang.Thread.run(Thread.java:1575) ``` The `mode` parameter no longer gets serialized for new indices. However on the older nodes still serialize the `mode` parameter, which caused the menioned assertion to fail. Reverting for now and see how best to address this bwc serialization issue. We can only stop serializing mode, when all nodes are on the same version. Unfortunately we can't invoke `c.clusterTransportVersion().get()` from parser or builder, because that calling thread isn't allowed to call `clusterService.state()`.
1 parent d03917d commit 1bc60ac

File tree

23 files changed

+133
-170
lines changed

23 files changed

+133
-170
lines changed

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/compat/compat/RestCompatTestTransformTask.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ public void skipTest(String fullTestName, String reason) {
135135
// For example: indices.get_mapping/20_missing_type/Non-existent type returns 404
136136
// However, the folder can be arbitrarily nest so, a == a1/a2/a3, and the test name can include forward slashes, so c == c1/c2/c3
137137
// So we also need to support a1/a2/a3/b/c1/c2/c3
138-
boolean limitTo3Separators = fullTestName.equals("logsdb/20_source_mapping/include/exclude is supported with stored _source");
139-
String[] testParts = limitTo3Separators ? fullTestName.split("/", 3) : fullTestName.split("/");
138+
139+
String[] testParts = fullTestName.split("/");
140140
if (testParts.length < 3) {
141141
throw new IllegalArgumentException(
142142
"To skip tests, all 3 parts [folder/file/test name] must be defined. found [" + fullTestName + "]"

docs/changelog/116689.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.

qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/LogsIndexModeFullClusterRestartIT.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.elasticsearch.common.network.InetAddresses;
1818
import org.elasticsearch.common.time.DateFormatter;
1919
import org.elasticsearch.common.time.FormatNames;
20+
import org.elasticsearch.test.MapMatcher;
2021
import org.elasticsearch.test.cluster.ElasticsearchCluster;
2122
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
2223
import org.elasticsearch.test.rest.RestTestLegacyFeatures;
@@ -30,6 +31,9 @@
3031
import java.util.Map;
3132
import java.util.function.Supplier;
3233

34+
import static org.elasticsearch.test.MapMatcher.assertMap;
35+
import static org.elasticsearch.test.MapMatcher.matchesMap;
36+
3337
public class LogsIndexModeFullClusterRestartIT extends ParameterizedFullClusterRestartTestCase {
3438

3539
@ClassRule
@@ -168,16 +172,22 @@ public void testLogsIndexing() throws IOException {
168172
assertOK(bulkIndexResponse);
169173
assertThat(entityAsMap(bulkIndexResponse).get("errors"), Matchers.is(false));
170174

171-
assertIndexSettings(0, Matchers.nullValue());
172-
assertIndexSettings(1, Matchers.equalTo("logsdb"));
175+
assertIndexMappingsAndSettings(0, Matchers.nullValue(), matchesMap().extraOk());
176+
assertIndexMappingsAndSettings(
177+
1,
178+
Matchers.equalTo("logsdb"),
179+
matchesMap().extraOk().entry("_source", Map.of("mode", "synthetic"))
180+
);
173181
}
174182
}
175183

176-
private void assertIndexSettings(int backingIndex, final Matcher<Object> indexModeMatcher) throws IOException {
184+
private void assertIndexMappingsAndSettings(int backingIndex, final Matcher<Object> indexModeMatcher, final MapMatcher mappingsMatcher)
185+
throws IOException {
177186
assertThat(
178187
getSettings(client(), getWriteBackingIndex(client(), "logs-apache-production", backingIndex)).get("index.mode"),
179188
indexModeMatcher
180189
);
190+
assertMap(getIndexMappingAsMap(getWriteBackingIndex(client(), "logs-apache-production", backingIndex)), mappingsMatcher);
181191
}
182192

183193
private static Request createDataStream(final String dataStreamName) {

qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/LogsIndexModeRollingUpgradeIT.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.elasticsearch.common.network.InetAddresses;
1818
import org.elasticsearch.common.time.DateFormatter;
1919
import org.elasticsearch.common.time.FormatNames;
20+
import org.elasticsearch.test.MapMatcher;
2021
import org.elasticsearch.test.cluster.ElasticsearchCluster;
2122
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
2223
import org.hamcrest.Matcher;
@@ -29,6 +30,9 @@
2930
import java.util.Map;
3031
import java.util.function.Supplier;
3132

33+
import static org.elasticsearch.test.MapMatcher.assertMap;
34+
import static org.elasticsearch.test.MapMatcher.matchesMap;
35+
3236
public class LogsIndexModeRollingUpgradeIT extends AbstractRollingUpgradeTestCase {
3337

3438
@ClassRule()
@@ -156,10 +160,14 @@ public void testLogsIndexing() throws IOException {
156160
assertOK(bulkIndexResponse);
157161
assertThat(entityAsMap(bulkIndexResponse).get("errors"), Matchers.is(false));
158162

159-
assertIndexSettings(0, Matchers.nullValue());
160-
assertIndexSettings(1, Matchers.nullValue());
161-
assertIndexSettings(2, Matchers.nullValue());
162-
assertIndexSettings(3, Matchers.equalTo("logsdb"));
163+
assertIndexMappingsAndSettings(0, Matchers.nullValue(), matchesMap().extraOk());
164+
assertIndexMappingsAndSettings(1, Matchers.nullValue(), matchesMap().extraOk());
165+
assertIndexMappingsAndSettings(2, Matchers.nullValue(), matchesMap().extraOk());
166+
assertIndexMappingsAndSettings(
167+
3,
168+
Matchers.equalTo("logsdb"),
169+
matchesMap().extraOk().entry("_source", Map.of("mode", "synthetic"))
170+
);
163171
}
164172
}
165173

@@ -175,11 +183,13 @@ static void enableLogsdbByDefault() throws IOException {
175183
assertOK(client().performRequest(request));
176184
}
177185

178-
private void assertIndexSettings(int backingIndex, final Matcher<Object> indexModeMatcher) throws IOException {
186+
private void assertIndexMappingsAndSettings(int backingIndex, final Matcher<Object> indexModeMatcher, final MapMatcher mappingsMatcher)
187+
throws IOException {
179188
assertThat(
180189
getSettings(client(), getWriteBackingIndex(client(), "logs-apache-production", backingIndex)).get("index.mode"),
181190
indexModeMatcher
182191
);
192+
assertMap(getIndexMappingAsMap(getWriteBackingIndex(client(), "logs-apache-production", backingIndex)), mappingsMatcher);
183193
}
184194

185195
private static Request createDataStream(final String dataStreamName) {

rest-api-spec/build.gradle

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,4 @@ tasks.named("precommit").configure {
247247
tasks.named("yamlRestTestV7CompatTransform").configure({ task ->
248248
task.skipTest("indices.sort/10_basic/Index Sort", "warning does not exist for compatibility")
249249
task.skipTest("search/330_fetch_fields/Test search rewrite", "warning does not exist for compatibility")
250-
task.skipTest("tsdb/20_mapping/stored source is supported", "no longer serialize source_mode")
251-
task.skipTest("tsdb/20_mapping/Synthetic source", "no longer serialize source_mode")
252-
task.skipTest("logsdb/10_settings/create logs index", "no longer serialize source_mode")
253-
task.skipTest("logsdb/20_source_mapping/stored _source mode is supported", "no longer serialize source_mode")
254-
task.skipTest("logsdb/20_source_mapping/include/exclude is supported with stored _source", "no longer serialize source_mode")
255-
task.skipTest("logsdb/20_source_mapping/synthetic _source is default", "no longer serialize source_mode")
256250
})

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/logsdb/10_settings.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ create logs index:
7777
- is_true: test
7878
- match: { test.settings.index.mode: "logsdb" }
7979

80+
- do:
81+
indices.get_mapping:
82+
index: test
83+
- match: { test.mappings._source.mode: synthetic }
84+
8085
---
8186
using default timestamp field mapping:
8287
- requires:

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/logsdb/20_source_mapping.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ synthetic _source is default:
1313
index:
1414
mode: logsdb
1515
- do:
16-
indices.get_settings:
16+
indices.get:
1717
index: test-default-source
18-
- match: { test-default-source.settings.index.mode: logsdb }
19-
- match: { test-default-source.settings.index.mapping.source.mode: null }
18+
19+
- match: { test-default-source.mappings._source.mode: "synthetic" }
2020

2121
---
2222
stored _source mode is supported:
@@ -28,12 +28,11 @@ stored _source mode is supported:
2828
index:
2929
mode: logsdb
3030
mapping.source.mode: stored
31-
3231
- do:
33-
indices.get_settings:
32+
indices.get:
3433
index: test-stored-source
35-
- match: { test-stored-source.settings.index.mode: logsdb }
36-
- match: { test-stored-source.settings.index.mapping.source.mode: stored }
34+
35+
- match: { test-stored-source.mappings._source.mode: "stored" }
3736

3837
---
3938
disabled _source is not supported:
@@ -111,6 +110,7 @@ include/exclude is supported with stored _source:
111110
indices.get:
112111
index: test-includes
113112

113+
- match: { test-includes.mappings._source.mode: "stored" }
114114
- match: { test-includes.mappings._source.includes: ["a"] }
115115

116116
- do:
@@ -129,4 +129,5 @@ include/exclude is supported with stored _source:
129129
indices.get:
130130
index: test-excludes
131131

132+
- match: { test-excludes.mappings._source.mode: "stored" }
132133
- match: { test-excludes.mappings._source.excludes: ["b"] }

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/20_mapping.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,11 @@ nested fields:
450450
type: long
451451
time_series_metric: gauge
452452

453+
- do:
454+
indices.get_mapping: {}
455+
456+
- match: {tsdb-synthetic.mappings._source.mode: synthetic}
457+
453458
---
454459
stored source is supported:
455460
- requires:
@@ -481,6 +486,12 @@ stored source is supported:
481486
type: keyword
482487
time_series_dimension: true
483488

489+
- do:
490+
indices.get:
491+
index: tsdb_index
492+
493+
- match: { tsdb_index.mappings._source.mode: "stored" }
494+
484495
---
485496
disabled source is not supported:
486497
- requires:

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
import org.elasticsearch.cluster.metadata.IndexMetadata;
1313
import org.elasticsearch.cluster.metadata.Metadata;
14-
import org.elasticsearch.cluster.service.ClusterService;
1514
import org.elasticsearch.common.compress.CompressedXContent;
1615
import org.elasticsearch.common.settings.Settings;
1716
import org.elasticsearch.core.CheckedFunction;
@@ -55,7 +54,7 @@ Settings getAdditionalIndexSettings(
5554
/**
5655
* Infrastructure class that holds services that can be used by {@link IndexSettingProvider} instances.
5756
*/
58-
record Parameters(ClusterService clusterService, CheckedFunction<IndexMetadata, MapperService, IOException> mapperServiceFactory) {
57+
record Parameters(CheckedFunction<IndexMetadata, MapperService, IOException> mapperServiceFactory) {
5958

6059
}
6160

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ private static IndexVersion def(int id, Version luceneVersion) {
121121
public static final IndexVersion ADD_ROLE_MAPPING_CLEANUP_MIGRATION = def(8_518_00_0, Version.LUCENE_9_12_0);
122122
public static final IndexVersion LOGSDB_DEFAULT_IGNORE_DYNAMIC_BEYOND_LIMIT_BACKPORT = def(8_519_00_0, Version.LUCENE_9_12_0);
123123
public static final IndexVersion TIME_BASED_K_ORDERED_DOC_ID_BACKPORT = def(8_520_00_0, Version.LUCENE_9_12_0);
124-
public static final IndexVersion DEPRECATE_SOURCE_MODE_MAPPER = def(8_521_00_0, Version.LUCENE_9_12_0);
125124
/*
126125
* STOP! READ THIS FIRST! No, really,
127126
* ____ _____ ___ ____ _ ____ _____ _ ____ _____ _ _ ___ ____ _____ ___ ____ ____ _____ _

0 commit comments

Comments
 (0)