From ee0d2e22e6e5b61c9c0648ba6d013b2dbb916164 Mon Sep 17 00:00:00 2001 From: Tanguy Leroux Date: Thu, 11 Feb 2021 09:16:53 +0100 Subject: [PATCH] Skip unreferenced files pruning after restore for searchable snapshots shards (#68821) (#68845) When a shard is restored from a snapshot there is an after restore step during which files on disk that are not referenced anymore by the restored segments infos file are deleted from disk. The deletion is executed using the Lucene.pruneUnreferencedFiles() method which opens a new IndexWriter and closes it in order to kick off Lucene's internal index files deleter. This step is not necessary for searchable snapshot shards which use the snapshot store type because such shards report a list of files coming from a shard snapshot which never contain unreferenced files. Skipping this step avoids extra unnecessary work when mounting a searchable snapshot index. --- .../repositories/blobstore/FileRestoreContext.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/repositories/blobstore/FileRestoreContext.java b/server/src/main/java/org/elasticsearch/repositories/blobstore/FileRestoreContext.java index 1321c3685b1dc..d2be6818b40ef 100644 --- a/server/src/main/java/org/elasticsearch/repositories/blobstore/FileRestoreContext.java +++ b/server/src/main/java/org/elasticsearch/repositories/blobstore/FileRestoreContext.java @@ -32,6 +32,7 @@ import static java.util.Collections.emptyMap; import static java.util.Collections.unmodifiableMap; +import static org.elasticsearch.index.IndexModule.INDEX_STORE_TYPE_SETTING; /** * This context will execute a file restore of the lucene files. It is primarily designed to be used to @@ -164,11 +165,14 @@ public void restore(SnapshotFiles snapshotFiles, Store store, ActionListener