Skip to content

Commit 68137b7

Browse files
committed
[8.x] Logsdb and source only snapshots.
Backporting elastic#122199 to 8.x branch. Addresses a few issues with logsdb and source only snapshots: * Avoid initializing index sorting, because sort fields will not have doc values. * Also disable doc value skippers when doc values get disabled. * As part of source only validation figure out what the nested parent field is. Also added a few more tests that snapshot and restore logsdb data streams.
1 parent c0ce37d commit 68137b7

File tree

4 files changed

+393
-1
lines changed

4 files changed

+393
-1
lines changed

docs/changelog/122199.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 122199
2+
summary: Fix issues that prevents using search only snapshots for indices that use index sorting. This is includes Logsdb and time series indices.
3+
area: Logs
4+
type: bug
5+
issues: []

server/src/main/java/org/elasticsearch/common/lucene/Lucene.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import org.apache.lucene.index.ConcurrentMergeScheduler;
2121
import org.apache.lucene.index.CorruptIndexException;
2222
import org.apache.lucene.index.DirectoryReader;
23+
import org.apache.lucene.index.FieldInfo;
24+
import org.apache.lucene.index.FieldInfos;
2325
import org.apache.lucene.index.FilterCodecReader;
2426
import org.apache.lucene.index.FilterDirectoryReader;
2527
import org.apache.lucene.index.FilterLeafReader;
@@ -189,14 +191,26 @@ public static SegmentInfos pruneUnreferencedFiles(String segmentsFileName, Direc
189191
throw new IllegalStateException("no commit found in the directory");
190192
}
191193
}
194+
// Need to figure out what the parent field is that, so that validation in IndexWriter doesn't fail
195+
// if no parent field is configured, but FieldInfo says there is a parent field.
196+
String parentField = null;
192197
final IndexCommit cp = getIndexCommit(si, directory);
198+
try (var reader = DirectoryReader.open(cp)) {
199+
var topLevelFieldInfos = FieldInfos.getMergedFieldInfos(reader);
200+
for (FieldInfo fieldInfo : topLevelFieldInfos) {
201+
if (fieldInfo.isParentField()) {
202+
parentField = fieldInfo.getName();
203+
}
204+
}
205+
}
193206
try (
194207
IndexWriter writer = new IndexWriter(
195208
directory,
196209
indexWriterConfigWithNoMerging(Lucene.STANDARD_ANALYZER).setSoftDeletesField(Lucene.SOFT_DELETES_FIELD)
197210
.setIndexCommit(cp)
198211
.setCommitOnClose(false)
199212
.setOpenMode(IndexWriterConfig.OpenMode.APPEND)
213+
.setParentField(parentField)
200214
)
201215
) {
202216
// do nothing and close this will kick off IndexFileDeleter which will remove all pending files

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ public IndexService(
232232
mapperMetrics
233233
);
234234
this.indexFieldData = new IndexFieldDataService(indexSettings, indicesFieldDataCache, circuitBreakerService);
235-
if (indexSettings.getIndexSortConfig().hasIndexSort()) {
235+
boolean sourceOnly = Boolean.parseBoolean(indexSettings.getSettings().get("index.source_only"));
236+
if (indexSettings.getIndexSortConfig().hasIndexSort() && sourceOnly == false) {
236237
// we delay the actual creation of the sort order for this index because the mapping has not been merged yet.
237238
// The sort order is validated right after the merge of the mapping later in the process.
238239
this.indexSortSupplier = () -> indexSettings.getIndexSortConfig()

0 commit comments

Comments
 (0)