Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.17] [8.x] Logsdb and source only snapshots. (#122572) #122595

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/122199.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 122199
summary: Fix issues that prevents using search only snapshots for indices that use index sorting. This is includes Logsdb and time series indices.
area: Logs
type: bug
issues: []
14 changes: 14 additions & 0 deletions server/src/main/java/org/elasticsearch/common/lucene/Lucene.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.apache.lucene.index.ConcurrentMergeScheduler;
import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.FieldInfos;
import org.apache.lucene.index.FilterCodecReader;
import org.apache.lucene.index.FilterDirectoryReader;
import org.apache.lucene.index.FilterLeafReader;
Expand Down Expand Up @@ -189,14 +191,26 @@ public static SegmentInfos pruneUnreferencedFiles(String segmentsFileName, Direc
throw new IllegalStateException("no commit found in the directory");
}
}
// Need to figure out what the parent field is that, so that validation in IndexWriter doesn't fail
// if no parent field is configured, but FieldInfo says there is a parent field.
String parentField = null;
final IndexCommit cp = getIndexCommit(si, directory);
try (var reader = DirectoryReader.open(cp)) {
var topLevelFieldInfos = FieldInfos.getMergedFieldInfos(reader);
for (FieldInfo fieldInfo : topLevelFieldInfos) {
if (fieldInfo.isParentField()) {
parentField = fieldInfo.getName();
}
}
}
try (
IndexWriter writer = new IndexWriter(
directory,
indexWriterConfigWithNoMerging(Lucene.STANDARD_ANALYZER).setSoftDeletesField(Lucene.SOFT_DELETES_FIELD)
.setIndexCommit(cp)
.setCommitOnClose(false)
.setOpenMode(IndexWriterConfig.OpenMode.APPEND)
.setParentField(parentField)
)
) {
// do nothing and close this will kick off IndexFileDeleter which will remove all pending files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ public IndexService(
mapperMetrics
);
this.indexFieldData = new IndexFieldDataService(indexSettings, indicesFieldDataCache, circuitBreakerService);
if (indexSettings.getIndexSortConfig().hasIndexSort()) {
boolean sourceOnly = Boolean.parseBoolean(indexSettings.getSettings().get("index.source_only"));
if (indexSettings.getIndexSortConfig().hasIndexSort() && sourceOnly == false) {
// we delay the actual creation of the sort order for this index because the mapping has not been merged yet.
// The sort order is validated right after the merge of the mapping later in the process.
this.indexSortSupplier = () -> indexSettings.getIndexSortConfig()
Expand Down
Loading