Skip to content

Commit 6209b4f

Browse files
authored
Add the USE_SYNTHETIC_SOURCE_FOR_RECOVERY_BACKPORT Index Version (#118450)
This PR introduces the backported `USE_SYNTHETIC_SOURCE_FOR_RECOVERY_BACKPORT` index version and updates the index version check to accommodate this addition.
1 parent 052f46a commit 6209b4f

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,11 @@ public void validate(Boolean enabled, Map<Setting<?>, Object> settings) {
688688

689689
// Verify that all nodes can handle this setting
690690
var version = (IndexVersion) settings.get(SETTING_INDEX_VERSION_CREATED);
691-
if (version.before(IndexVersions.USE_SYNTHETIC_SOURCE_FOR_RECOVERY)) {
691+
if (version.before(IndexVersions.USE_SYNTHETIC_SOURCE_FOR_RECOVERY)
692+
&& version.between(
693+
IndexVersions.USE_SYNTHETIC_SOURCE_FOR_RECOVERY_BACKPORT,
694+
IndexVersions.UPGRADE_TO_LUCENE_10_0_0
695+
) == false) {
692696
throw new IllegalArgumentException(
693697
String.format(
694698
Locale.ROOT,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ private static Version parseUnchecked(String version) {
132132
public static final IndexVersion LOGSDB_DEFAULT_IGNORE_DYNAMIC_BEYOND_LIMIT_BACKPORT = def(8_519_00_0, Version.LUCENE_9_12_0);
133133
public static final IndexVersion TIME_BASED_K_ORDERED_DOC_ID_BACKPORT = def(8_520_00_0, Version.LUCENE_9_12_0);
134134
public static final IndexVersion V8_DEPRECATE_SOURCE_MODE_MAPPER = def(8_521_00_0, Version.LUCENE_9_12_0);
135+
public static final IndexVersion USE_SYNTHETIC_SOURCE_FOR_RECOVERY_BACKPORT = def(8_522_00_0, Version.LUCENE_9_12_0);
135136
public static final IndexVersion UPGRADE_TO_LUCENE_10_0_0 = def(9_000_00_0, Version.LUCENE_10_0_0);
136137
public static final IndexVersion LOGSDB_DEFAULT_IGNORE_DYNAMIC_BEYOND_LIMIT = def(9_001_00_0, Version.LUCENE_10_0_0);
137138
public static final IndexVersion TIME_BASED_K_ORDERED_DOC_ID = def(9_002_00_0, Version.LUCENE_10_0_0);

server/src/test/java/org/elasticsearch/index/mapper/SourceFieldMapperTests.java

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,36 @@ public void testRecoverySourceWitInvalidSettings() {
473473
IllegalArgumentException exc = expectThrows(
474474
IllegalArgumentException.class,
475475
() -> createMapperService(
476-
IndexVersionUtils.randomPreviousCompatibleVersion(random(), IndexVersions.USE_SYNTHETIC_SOURCE_FOR_RECOVERY),
476+
IndexVersionUtils.randomPreviousCompatibleVersion(random(), IndexVersions.USE_SYNTHETIC_SOURCE_FOR_RECOVERY_BACKPORT),
477+
settings,
478+
() -> false,
479+
topMapping(b -> {})
480+
)
481+
);
482+
assertThat(
483+
exc.getMessage(),
484+
containsString(
485+
String.format(
486+
Locale.ROOT,
487+
"The setting [%s] is unavailable on this cluster",
488+
IndexSettings.RECOVERY_USE_SYNTHETIC_SOURCE_SETTING.getKey()
489+
)
490+
)
491+
);
492+
}
493+
{
494+
Settings settings = Settings.builder()
495+
.put(SourceFieldMapper.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), SourceFieldMapper.Mode.SYNTHETIC.toString())
496+
.put(IndexSettings.RECOVERY_USE_SYNTHETIC_SOURCE_SETTING.getKey(), true)
497+
.build();
498+
IllegalArgumentException exc = expectThrows(
499+
IllegalArgumentException.class,
500+
() -> createMapperService(
501+
IndexVersionUtils.randomVersionBetween(
502+
random(),
503+
IndexVersions.UPGRADE_TO_LUCENE_10_0_0,
504+
IndexVersions.DEPRECATE_SOURCE_MODE_MAPPER
505+
),
477506
settings,
478507
() -> false,
479508
topMapping(b -> {})

0 commit comments

Comments
 (0)