Skip to content

Commit

Permalink
Enable prewarming by default for searchable snapshots (elastic#56201)
Browse files Browse the repository at this point in the history
Now searchable snapshots directories respect the repository 
rate limitations (elastic#55952) we can enable prewarming by default 
for shards.
  • Loading branch information
tlrx committed May 6, 2020
1 parent 6a69ab4 commit 6540efd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public class SearchableSnapshots extends Plugin implements IndexStorePlugin, Eng
);
public static final Setting<Boolean> SNAPSHOT_CACHE_PREWARM_ENABLED_SETTING = Setting.boolSetting(
"index.store.snapshot.cache.prewarm.enabled",
false,
true,
Setting.Property.IndexScope
);
// The file extensions that are excluded from the cache
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import static org.elasticsearch.index.store.cache.TestUtils.createCacheService;
import static org.elasticsearch.index.store.cache.TestUtils.singleBlobContainer;
import static org.elasticsearch.xpack.searchablesnapshots.SearchableSnapshots.SNAPSHOT_CACHE_ENABLED_SETTING;
import static org.elasticsearch.xpack.searchablesnapshots.SearchableSnapshots.SNAPSHOT_CACHE_PREWARM_ENABLED_SETTING;
import static org.elasticsearch.xpack.searchablesnapshots.SearchableSnapshots.SNAPSHOT_UNCACHED_CHUNK_SIZE_SETTING;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.equalTo;
Expand Down Expand Up @@ -519,7 +520,10 @@ public void testBackwardSeeks() {
private static void executeTestCase(final TriConsumer<String, byte[], SearchableSnapshotDirectory> test) {
executeTestCase(
createCacheService(random()),
Settings.builder().put(SNAPSHOT_CACHE_ENABLED_SETTING.getKey(), randomBoolean()).build(),
Settings.builder()
.put(SNAPSHOT_CACHE_ENABLED_SETTING.getKey(), randomBoolean())
.put(SNAPSHOT_CACHE_PREWARM_ENABLED_SETTING.getKey(), false) // disable prewarming as it impacts the stats
.build(),
test
);
}
Expand Down Expand Up @@ -553,7 +557,10 @@ private static void executeTestCaseWithCache(
) {
executeTestCase(
new CacheService(cacheSize, cacheRangeSize),
Settings.builder().put(SNAPSHOT_CACHE_ENABLED_SETTING.getKey(), true).build(),
Settings.builder()
.put(SNAPSHOT_CACHE_ENABLED_SETTING.getKey(), true)
.put(SNAPSHOT_CACHE_PREWARM_ENABLED_SETTING.getKey(), false) // disable prewarming as it impacts the stats
.build(),
test
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public void testThrowsEOFException() throws IOException {
);

final BlobContainer blobContainer = singleBlobContainer(blobName, input);

final ThreadPool threadPool = new TestThreadPool(getTestName(), SearchableSnapshots.executorBuilder());
final Path cacheDir = createTempDir();
try (
SearchableSnapshotDirectory searchableSnapshotDirectory = new SearchableSnapshotDirectory(
Expand All @@ -170,7 +170,7 @@ public void testThrowsEOFException() throws IOException {
() -> 0L,
cacheService,
cacheDir,
null
threadPool
)
) {
final boolean loaded = searchableSnapshotDirectory.loadSnapshot();
Expand All @@ -185,6 +185,8 @@ public void testThrowsEOFException() throws IOException {
throw new AssertionError("inner EOFException not thrown", exception);
}
}
} finally {
terminate(threadPool);
}
}
}
Expand Down

0 comments on commit 6540efd

Please sign in to comment.