Skip to content

Commit 5940c72

Browse files
Merge branch 'main' into merge-disk-space-aware-take-2
2 parents 1b767b6 + df82c06 commit 5940c72

File tree

43 files changed

+685
-161
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+685
-161
lines changed

docs/changelog/128139.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 128139
2+
summary: Skip indexing points for `seq_no` in tsdb and logsdb
3+
area: Mapping
4+
type: enhancement
5+
issues: []

docs/changelog/128163.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
pr: 128163
2+
summary: Make `skip_unavailable` catch all errors
3+
area: ES|QL
4+
type: breaking
5+
issues: [ ]
6+
breaking:
7+
title: Cluster setting "skip_unavailable" catches all runtime errors
8+
area: ES|QL
9+
details: "If `skip_unavailable` is set to `true`, the runtime errors from this cluster\
10+
\ do not lead to a failure of the query. Instead, the cluster is set to `skipped`\
11+
\ or `partial` status, and the query execution continues. This is a breaking change\
12+
\ from previous versions, where `skip_unavailable` only applied to errors related\
13+
\ to a cluster being unavailable."
14+
impact: "The errors on remote clusters, e.g. missing indices, will not lead to a\
15+
\ failure of the query. Instead, the cluster is set to `skipped` or `partial` status\
16+
\ in the response metadata."
17+
notable: false

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.elasticsearch.common.util.concurrent.EsExecutors;
3434
import org.elasticsearch.core.TimeValue;
3535
import org.elasticsearch.index.Index;
36+
import org.elasticsearch.index.IndexSettings;
3637
import org.elasticsearch.indices.SystemIndices;
3738
import org.elasticsearch.injection.guice.Inject;
3839
import org.elasticsearch.tasks.Task;
@@ -53,7 +54,7 @@ public class TransportUpdateDataStreamSettingsAction extends TransportMasterNode
5354
UpdateDataStreamSettingsAction.Request,
5455
UpdateDataStreamSettingsAction.Response> {
5556
private static final Logger logger = LogManager.getLogger(TransportUpdateDataStreamSettingsAction.class);
56-
private static final Set<String> APPLY_TO_BACKING_INDICES = Set.of("index.lifecycle.name");
57+
private static final Set<String> APPLY_TO_BACKING_INDICES = Set.of("index.lifecycle.name", IndexSettings.PREFER_ILM);
5758
private static final Set<String> APPLY_TO_DATA_STREAM_ONLY = Set.of("index.number_of_shards");
5859
private final MetadataDataStreamsService metadataDataStreamsService;
5960
private final MetadataUpdateSettingsService updateSettingsService;

modules/data-streams/src/yamlRestTest/resources/rest-api-spec/test/data_stream/240_data_stream_settings.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,20 @@ setup:
5151
body:
5252
index:
5353
number_of_shards: 2
54-
lifecycle.name: my-new-policy
54+
lifecycle:
55+
name: my-new-policy
56+
prefer_ilm: true
5557
- match: { data_streams.0.name: my-data-stream-1 }
5658
- match: { data_streams.0.applied_to_data_stream: true }
5759
- match: { data_streams.0.index_settings_results.applied_to_data_stream_only: [index.number_of_shards]}
58-
- match: { data_streams.0.index_settings_results.applied_to_data_stream_and_backing_indices: [index.lifecycle.name] }
60+
- length: { data_streams.0.index_settings_results.applied_to_data_stream_and_backing_indices: 2 }
5961
- match: { data_streams.0.settings.index.number_of_shards: "2" }
6062
- match: { data_streams.0.settings.index.lifecycle.name: "my-new-policy" }
63+
- match: { data_streams.0.settings.index.lifecycle.prefer_ilm: "true" }
6164
- match: { data_streams.0.effective_settings.index.number_of_shards: "2" }
6265
- match: { data_streams.0.effective_settings.index.number_of_replicas: "0" }
6366
- match: { data_streams.0.effective_settings.index.lifecycle.name: "my-new-policy" }
67+
- match: { data_streams.0.effective_settings.index.lifecycle.prefer_ilm: "true" }
6468

6569
- do:
6670
indices.rollover:
@@ -79,13 +83,15 @@ setup:
7983
- match: { data_streams.0.effective_settings.index.number_of_shards: "2" }
8084
- match: { data_streams.0.effective_settings.index.number_of_replicas: "0" }
8185
- match: { data_streams.0.effective_settings.index.lifecycle.name: "my-new-policy" }
86+
- match: { data_streams.0.effective_settings.index.lifecycle.prefer_ilm: "true" }
8287

8388
- do:
8489
indices.get_data_stream:
8590
name: my-data-stream-1
8691
- match: { data_streams.0.name: my-data-stream-1 }
8792
- match: { data_streams.0.settings.index.number_of_shards: "2" }
8893
- match: { data_streams.0.settings.index.lifecycle.name: "my-new-policy" }
94+
- match: { data_streams.0.settings.index.lifecycle.prefer_ilm: "true" }
8995
- match: { data_streams.0.effective_settings: null }
9096

9197
- do:
@@ -101,6 +107,7 @@ setup:
101107
- match: { .$idx0name.settings.index.lifecycle.name: "my-new-policy" }
102108
- match: { .$idx1name.settings.index.number_of_shards: "2" }
103109
- match: { .$idx1name.settings.index.lifecycle.name: "my-new-policy" }
110+
- match: { .$idx1name.settings.index.lifecycle.prefer_ilm: "true" }
104111

105112
---
106113
"Test multiple data streams":

muted-tests.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,11 @@ tests:
486486
- class: org.elasticsearch.xpack.esql.plugin.DataNodeRequestSenderIT
487487
method: testSearchWhileRelocating
488488
issue: https://github.com/elastic/elasticsearch/issues/128500
489+
- class: org.elasticsearch.xpack.esql.ccq.EsqlRestValidationIT
490+
issue: https://github.com/elastic/elasticsearch/issues/128543
491+
- class: org.elasticsearch.xpack.ccr.index.engine.FollowingEngineTests
492+
method: testProcessOnceOnPrimary
493+
issue: https://github.com/elastic/elasticsearch/issues/128541
489494

490495
# Examples:
491496
#

server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/diskusage/IndexDiskUsageAnalyzerIT.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import java.util.Collection;
3737
import java.util.List;
3838
import java.util.Optional;
39+
import java.util.Random;
3940
import java.util.Set;
4041
import java.util.concurrent.atomic.AtomicInteger;
4142
import java.util.stream.IntStream;
@@ -61,6 +62,13 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {
6162
return plugins;
6263
}
6364

65+
@Override
66+
protected Settings.Builder setRandomIndexSettings(Random random, Settings.Builder builder) {
67+
var b = super.setRandomIndexSettings(random, builder);
68+
b.remove(IndexSettings.SEQ_NO_INDEX_OPTIONS_SETTING.getKey());
69+
return b;
70+
}
71+
6472
private static final Set<ShardId> failOnFlushShards = ConcurrentCollections.newConcurrentSet();
6573

6674
public static class EngineTestPlugin extends Plugin implements EnginePlugin {

server/src/main/java/org/elasticsearch/common/settings/IndexScopedSettings.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ public final class IndexScopedSettings extends AbstractScopedSettings {
224224
IndexMetadata.INDEX_ROUTING_PATH,
225225
IndexSettings.TIME_SERIES_START_TIME,
226226
IndexSettings.TIME_SERIES_END_TIME,
227+
IndexSettings.SEQ_NO_INDEX_OPTIONS_SETTING,
227228

228229
// Legacy index settings we must keep around for BWC from 7.x
229230
EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS,

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.elasticsearch.core.TimeValue;
2929
import org.elasticsearch.index.mapper.IgnoredSourceFieldMapper;
3030
import org.elasticsearch.index.mapper.Mapper;
31+
import org.elasticsearch.index.mapper.SeqNoFieldMapper;
3132
import org.elasticsearch.index.mapper.SourceFieldMapper;
3233
import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper;
3334
import org.elasticsearch.index.translog.Translog;
@@ -829,6 +830,23 @@ private static String getIgnoreAboveDefaultValue(final Settings settings) {
829830
}
830831
}
831832

833+
public static final Setting<SeqNoFieldMapper.SeqNoIndexOptions> SEQ_NO_INDEX_OPTIONS_SETTING = Setting.enumSetting(
834+
SeqNoFieldMapper.SeqNoIndexOptions.class,
835+
settings -> {
836+
final IndexMode indexMode = IndexSettings.MODE.get(settings);
837+
if ((indexMode == IndexMode.LOGSDB || indexMode == IndexMode.TIME_SERIES)
838+
&& IndexMetadata.SETTING_INDEX_VERSION_CREATED.get(settings).onOrAfter(IndexVersions.SEQ_NO_WITHOUT_POINTS)) {
839+
return SeqNoFieldMapper.SeqNoIndexOptions.DOC_VALUES_ONLY.toString();
840+
} else {
841+
return SeqNoFieldMapper.SeqNoIndexOptions.POINTS_AND_DOC_VALUES.toString();
842+
}
843+
},
844+
"index.seq_no.index_options",
845+
value -> {},
846+
Property.IndexScope,
847+
Property.Final
848+
);
849+
832850
private final Index index;
833851
private final IndexVersion version;
834852
private final Logger logger;
@@ -933,6 +951,7 @@ private void setRetentionLeaseMillis(final TimeValue retentionLease) {
933951
private volatile int maxRegexLength;
934952

935953
private final IndexRouting indexRouting;
954+
private final SeqNoFieldMapper.SeqNoIndexOptions seqNoIndexOptions;
936955

937956
/**
938957
* The default mode for storing source, for all mappers not overriding this setting.
@@ -1099,6 +1118,7 @@ public IndexSettings(final IndexMetadata indexMetadata, final Settings nodeSetti
10991118
recoverySourceSyntheticEnabled = DiscoveryNode.isStateless(nodeSettings) == false
11001119
&& scopedSettings.get(RECOVERY_USE_SYNTHETIC_SOURCE_SETTING);
11011120
useDocValuesSkipper = DOC_VALUES_SKIPPER && scopedSettings.get(USE_DOC_VALUES_SKIPPER);
1121+
seqNoIndexOptions = scopedSettings.get(SEQ_NO_INDEX_OPTIONS_SETTING);
11021122
if (recoverySourceSyntheticEnabled) {
11031123
if (DiscoveryNode.isStateless(settings)) {
11041124
throw new IllegalArgumentException("synthetic recovery source is only allowed in stateful");
@@ -1837,4 +1857,8 @@ public DenseVectorFieldMapper.FilterHeuristic getHnswFilterHeuristic() {
18371857
private void setHnswFilterHeuristic(DenseVectorFieldMapper.FilterHeuristic heuristic) {
18381858
this.hnswFilterHeuristic = heuristic;
18391859
}
1860+
1861+
public SeqNoFieldMapper.SeqNoIndexOptions seqNoIndexOptions() {
1862+
return seqNoIndexOptions;
1863+
}
18401864
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ private static Version parseUnchecked(String version) {
168168
public static final IndexVersion DEFAULT_OVERSAMPLE_VALUE_FOR_BBQ = def(9_024_0_00, Version.LUCENE_10_2_1);
169169
public static final IndexVersion SEMANTIC_TEXT_DEFAULTS_TO_BBQ = def(9_025_0_00, Version.LUCENE_10_2_1);
170170
public static final IndexVersion DEFAULT_TO_ACORN_HNSW_FILTER_HEURISTIC = def(9_026_0_00, Version.LUCENE_10_2_1);
171+
public static final IndexVersion SEQ_NO_WITHOUT_POINTS = def(9_027_0_00, Version.LUCENE_10_2_1);
171172
/*
172173
* STOP! READ THIS FIRST! No, really,
173174
* ____ _____ ___ ____ _ ____ _____ _ ____ _____ _ _ ___ ____ _____ ___ ____ ____ _____ _

server/src/main/java/org/elasticsearch/index/engine/InternalEngine.java

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
package org.elasticsearch.index.engine;
1111

1212
import org.apache.logging.log4j.Logger;
13-
import org.apache.lucene.document.LongPoint;
1413
import org.apache.lucene.document.NumericDocValuesField;
1514
import org.apache.lucene.index.DirectoryReader;
1615
import org.apache.lucene.index.IndexCommit;
@@ -1811,7 +1810,10 @@ private DeletionStrategy planDeletionAsPrimary(Delete delete) throws IOException
18111810
private DeleteResult deleteInLucene(Delete delete, DeletionStrategy plan) throws IOException {
18121811
assert assertMaxSeqNoOfUpdatesIsAdvanced(delete.uid(), delete.seqNo(), false, false);
18131812
try {
1814-
final ParsedDocument tombstone = ParsedDocument.deleteTombstone(delete.id());
1813+
final ParsedDocument tombstone = ParsedDocument.deleteTombstone(
1814+
engineConfig.getIndexSettings().seqNoIndexOptions(),
1815+
delete.id()
1816+
);
18151817
assert tombstone.docs().size() == 1 : "Tombstone doc should have single doc [" + tombstone + "]";
18161818
tombstone.updateSeqID(delete.seqNo(), delete.primaryTerm());
18171819
tombstone.version().setLongValue(plan.versionOfDeletion);
@@ -1970,7 +1972,10 @@ private NoOpResult innerNoOp(final NoOp noOp) throws IOException {
19701972
markSeqNoAsSeen(noOp.seqNo());
19711973
if (hasBeenProcessedBefore(noOp) == false) {
19721974
try {
1973-
final ParsedDocument tombstone = ParsedDocument.noopTombstone(noOp.reason());
1975+
final ParsedDocument tombstone = ParsedDocument.noopTombstone(
1976+
engineConfig.getIndexSettings().seqNoIndexOptions(),
1977+
noOp.reason()
1978+
);
19741979
tombstone.updateSeqID(noOp.seqNo(), noOp.primaryTerm());
19751980
// A noop tombstone does not require a _version but it's added to have a fully dense docvalues for the version
19761981
// field. 1L is selected to optimize the compression because it might probably be the most common value in
@@ -2753,10 +2758,10 @@ private IndexWriterConfig getIndexWriterConfig() {
27532758
? SourceFieldMapper.RECOVERY_SOURCE_SIZE_NAME
27542759
: SourceFieldMapper.RECOVERY_SOURCE_NAME,
27552760
engineConfig.getIndexSettings().getMode() == IndexMode.TIME_SERIES,
2756-
softDeletesPolicy::getRetentionQuery,
2761+
() -> softDeletesPolicy.getRetentionQuery(engineConfig.getIndexSettings().seqNoIndexOptions()),
27572762
new SoftDeletesRetentionMergePolicy(
27582763
Lucene.SOFT_DELETES_FIELD,
2759-
softDeletesPolicy::getRetentionQuery,
2764+
() -> softDeletesPolicy.getRetentionQuery(engineConfig.getIndexSettings().seqNoIndexOptions()),
27602765
new PrunePostingsMergePolicy(mergePolicy, IdFieldMapper.NAME)
27612766
)
27622767
);
@@ -3215,12 +3220,7 @@ public int countChanges(String source, long fromSeqNo, long toSeqNo) throws IOEx
32153220
ensureOpen();
32163221
refreshIfNeeded(source, toSeqNo);
32173222
try (Searcher searcher = acquireSearcher(source, SearcherScope.INTERNAL)) {
3218-
return LuceneChangesSnapshot.countOperations(
3219-
searcher,
3220-
fromSeqNo,
3221-
toSeqNo,
3222-
config().getIndexSettings().getIndexVersionCreated()
3223-
);
3223+
return LuceneChangesSnapshot.countOperations(searcher, engineConfig.getIndexSettings(), fromSeqNo, toSeqNo);
32243224
} catch (Exception e) {
32253225
try {
32263226
maybeFailEngine("count changes", e);
@@ -3448,7 +3448,11 @@ private void restoreVersionMapAndCheckpointTracker(DirectoryReader directoryRead
34483448
final IndexSearcher searcher = new IndexSearcher(directoryReader);
34493449
searcher.setQueryCache(null);
34503450
final Query query = new BooleanQuery.Builder().add(
3451-
LongPoint.newRangeQuery(SeqNoFieldMapper.NAME, getPersistedLocalCheckpoint() + 1, Long.MAX_VALUE),
3451+
SeqNoFieldMapper.rangeQueryForSeqNo(
3452+
engineConfig.getIndexSettings().seqNoIndexOptions(),
3453+
getPersistedLocalCheckpoint() + 1,
3454+
Long.MAX_VALUE
3455+
),
34523456
BooleanClause.Occur.MUST
34533457
)
34543458
.add(Queries.newNonNestedFilter(indexVersionCreated), BooleanClause.Occur.MUST) // exclude non-root nested documents

0 commit comments

Comments
 (0)