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

Introduce index based snapshot blob cache for Searchable Snapshots #60522

Merged
merged 70 commits into from
Aug 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
d001419
Introduce index based snapshot blob cache for Searchable Snapshots
tlrx Jul 31, 2020
c4f251c
WIP adjust some logging and back out cache-size-times-two optimisation
DaveCTurner Aug 4, 2020
1f30c42
Avoid ActionListener#wrap
DaveCTurner Aug 6, 2020
02a8ed1
Add TODO
DaveCTurner Aug 6, 2020
76b97ab
Move special openInputStream impl
DaveCTurner Aug 6, 2020
df7c0b5
Add TODOs
DaveCTurner Aug 6, 2020
922c381
Add TODOs
DaveCTurner Aug 6, 2020
c24d78e
Rework implementation
DaveCTurner Aug 7, 2020
7e5bbc4
Merge branch 'master' into poc-blob-cache
DaveCTurner Aug 7, 2020
1b459ae
One-shot reading
DaveCTurner Aug 7, 2020
f06e0ae
Try to fill the cache miss rather than immediately failing
DaveCTurner Aug 10, 2020
c5b65bc
No need for a list with <= 1 element
DaveCTurner Aug 10, 2020
974c095
Reorder defs
DaveCTurner Aug 10, 2020
2abf126
Mapping tweaks
DaveCTurner Aug 10, 2020
dad98d8
Merge branch 'master' into poc-blob-cache
DaveCTurner Aug 11, 2020
4c8ed35
No need to index fields, we only get by ID
DaveCTurner Aug 11, 2020
4b6798a
Comment
DaveCTurner Aug 11, 2020
8a3b174
Rename
DaveCTurner Aug 11, 2020
80e42ff
Assert no more indexing into cache after first startup
DaveCTurner Aug 11, 2020
b052d7e
Stronger assertions about what is read from the blob store when the c…
DaveCTurner Aug 11, 2020
d4919fa
No need for a fake blob store when we track accesses in the index inp…
DaveCTurner Aug 11, 2020
d2632ee
Assert no indexing at all after restart
DaveCTurner Aug 11, 2020
4df37d6
Merge branch 'master' into poc-blob-cache
DaveCTurner Aug 14, 2020
24f646f
Block test until cache fills are complete
DaveCTurner Aug 14, 2020
5e752dd
Add debugging
DaveCTurner Aug 14, 2020
5502545
Merge branch 'master' into poc-blob-cache
DaveCTurner Aug 18, 2020
61701fe
Revert
DaveCTurner Aug 18, 2020
f5948c4
Moar revert
DaveCTurner Aug 18, 2020
51a81ac
Revert
DaveCTurner Aug 18, 2020
7116f9f
Revert buffer size increase
DaveCTurner Aug 18, 2020
4b01c9a
Better assertion
DaveCTurner Aug 18, 2020
d3d58cd
Distinguish definite cache miss from cache-not-ready
DaveCTurner Aug 18, 2020
0bcabe1
Precommit
DaveCTurner Aug 18, 2020
43f281a
Test bug
DaveCTurner Aug 18, 2020
78680be
Track reads from index cache too
DaveCTurner Aug 18, 2020
c50dfa6
Retry on INFE
DaveCTurner Aug 19, 2020
d6ef9cd
Always put a missing cache entry even if cache not ready
DaveCTurner Aug 20, 2020
03a575e
Merge branch 'master' into poc-blob-cache
DaveCTurner Aug 20, 2020
4f9584c
Let's keep indexing things for now
DaveCTurner Aug 20, 2020
cd77a43
Unnecessary repo
DaveCTurner Aug 20, 2020
7aa25d0
Merge branch 'master' into poc-blob-cache
DaveCTurner Aug 24, 2020
1c38aaa
Less allocation
DaveCTurner Aug 24, 2020
0fbb71f
Use TransportActions.isShardNotAvailableException
DaveCTurner Aug 24, 2020
7e6eb53
Always notify listener
DaveCTurner Aug 24, 2020
6391d8f
Propagate direct exception directly to caller
DaveCTurner Aug 24, 2020
7bd0e47
Also permit disconnected/not-connected/node-closed exceptions, and as…
DaveCTurner Aug 24, 2020
60ceabb
Precommit
DaveCTurner Aug 24, 2020
b50d158
Check the cache index even after recovery complete
DaveCTurner Aug 24, 2020
d53443e
Collect timings for cache index reads
DaveCTurner Aug 24, 2020
299443f
Assert enough space
DaveCTurner Aug 24, 2020
8b607b0
Fix bytes-read stats
DaveCTurner Aug 25, 2020
dbf6f2f
Revert back to untimed counter
DaveCTurner Aug 25, 2020
e8bc561
Another revert to counter
DaveCTurner Aug 25, 2020
1172e68
Avoid allocation reading cached blob
DaveCTurner Aug 25, 2020
181b1f5
Allow waiting for a cache file range without committing to filling an…
DaveCTurner Aug 25, 2020
abdbf3c
No longer need to track whether recovery is done
DaveCTurner Aug 25, 2020
38bf697
No need to wait for fetch threads to be idle
DaveCTurner Aug 25, 2020
9fbf8ce
Delete restored index first to make sure it doesn't re-create the cac…
DaveCTurner Aug 25, 2020
ec9cd24
Remove test logging
DaveCTurner Aug 25, 2020
1535e58
And another one
DaveCTurner Aug 25, 2020
790bdc1
Merge branch 'master' into poc-blob-cache
DaveCTurner Aug 25, 2020
eb1a08e
Time out cache get after 5s
DaveCTurner Aug 26, 2020
deda305
Assert not blocking a SYSTEM_READ thread
DaveCTurner Aug 26, 2020
dad5dfd
Spotless
DaveCTurner Aug 26, 2020
99045e0
Delimiters
DaveCTurner Aug 26, 2020
2003ec0
Add stats to tests
DaveCTurner Aug 26, 2020
62fe090
Catch exception during indexing
DaveCTurner Aug 26, 2020
2c2a7c0
Remove duplicate assertion
DaveCTurner Aug 26, 2020
bb6d4ab
Another test needing cleanup
DaveCTurner Aug 26, 2020
9e228c1
Account for 'any kind' reads from index cache
DaveCTurner Aug 26, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -1223,6 +1223,7 @@ protected static boolean isXPackTemplate(String name) {
case "metrics":
case "metrics-settings":
case "metrics-mappings":
case ".snapshot-blob-cache":
return true;
default:
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public static Map<String, String> filterSecurityHeaders(Map<String, String> head
public static final String ASYNC_SEARCH_ORIGIN = "async_search";
public static final String IDP_ORIGIN = "idp";
public static final String STACK_ORIGIN = "stack";
public static final String SEARCHABLE_SNAPSHOTS_ORIGIN = "searchable_snapshots";

private ClientHelper() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
package org.elasticsearch.xpack.core.searchablesnapshots;

import org.elasticsearch.Version;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
Expand Down Expand Up @@ -134,16 +135,20 @@ public static class CacheIndexInputStats implements Writeable, ToXContentObject
private final Counter contiguousReads;
private final Counter nonContiguousReads;
private final Counter cachedBytesRead;
private final Counter indexCacheBytesRead;
private final TimedCounter cachedBytesWritten;
private final TimedCounter directBytesRead;
private final TimedCounter optimizedBytesRead;
private final Counter blobStoreBytesRequested;
private final long currentIndexCacheFills;

public CacheIndexInputStats(String fileName, long fileLength, long openCount, long closeCount,
Counter forwardSmallSeeks, Counter backwardSmallSeeks,
Counter forwardLargeSeeks, Counter backwardLargeSeeks,
Counter contiguousReads, Counter nonContiguousReads,
Counter cachedBytesRead, TimedCounter cachedBytesWritten,
TimedCounter directBytesRead, TimedCounter optimizedBytesRead) {
Counter cachedBytesRead, Counter indexCacheBytesRead,
TimedCounter cachedBytesWritten, TimedCounter directBytesRead, TimedCounter optimizedBytesRead,
Counter blobStoreBytesRequested, long currentIndexCacheFills) {
this.fileName = fileName;
this.fileLength = fileLength;
this.openCount = openCount;
Expand All @@ -155,9 +160,12 @@ public CacheIndexInputStats(String fileName, long fileLength, long openCount, lo
this.contiguousReads = contiguousReads;
this.nonContiguousReads = nonContiguousReads;
this.cachedBytesRead = cachedBytesRead;
this.indexCacheBytesRead = indexCacheBytesRead;
this.cachedBytesWritten = cachedBytesWritten;
this.directBytesRead = directBytesRead;
this.optimizedBytesRead = optimizedBytesRead;
this.blobStoreBytesRequested = blobStoreBytesRequested;
this.currentIndexCacheFills = currentIndexCacheFills;
}

CacheIndexInputStats(final StreamInput in) throws IOException {
Expand All @@ -172,9 +180,21 @@ public CacheIndexInputStats(String fileName, long fileLength, long openCount, lo
this.contiguousReads = new Counter(in);
this.nonContiguousReads = new Counter(in);
this.cachedBytesRead = new Counter(in);
if (in.getVersion().onOrAfter(Version.V_8_0_0)) {
this.indexCacheBytesRead = new Counter(in);
} else {
this.indexCacheBytesRead = new Counter(0, 0, 0, 0);
}
this.cachedBytesWritten = new TimedCounter(in);
this.directBytesRead = new TimedCounter(in);
this.optimizedBytesRead = new TimedCounter(in);
if (in.getVersion().onOrAfter(Version.V_8_0_0)) {
this.blobStoreBytesRequested = new Counter(in);
this.currentIndexCacheFills = in.readVLong();
} else {
this.blobStoreBytesRequested = new Counter(0, 0, 0, 0);
this.currentIndexCacheFills = 0;
}
}

@Override
Expand All @@ -191,9 +211,16 @@ public void writeTo(StreamOutput out) throws IOException {
contiguousReads.writeTo(out);
nonContiguousReads.writeTo(out);
cachedBytesRead.writeTo(out);
if (out.getVersion().onOrAfter(Version.V_8_0_0)) {
indexCacheBytesRead.writeTo(out);
}
cachedBytesWritten.writeTo(out);
directBytesRead.writeTo(out);
optimizedBytesRead.writeTo(out);
if (out.getVersion().onOrAfter(Version.V_8_0_0)) {
blobStoreBytesRequested.writeTo(out);
out.writeVLong(currentIndexCacheFills);
}
}

public String getFileName() {
Expand Down Expand Up @@ -240,6 +267,10 @@ public Counter getCachedBytesRead() {
return cachedBytesRead;
}

public Counter getIndexCacheBytesRead() {
return indexCacheBytesRead;
}

public TimedCounter getCachedBytesWritten() {
return cachedBytesWritten;
}
Expand All @@ -252,6 +283,14 @@ public TimedCounter getOptimizedBytesRead() {
return optimizedBytesRead;
}

public Counter getBlobStoreBytesRequested() {
return blobStoreBytesRequested;
}

public long getCurrentIndexCacheFills() {
return currentIndexCacheFills;
}

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
Expand All @@ -263,6 +302,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
builder.field("contiguous_bytes_read", getContiguousReads());
builder.field("non_contiguous_bytes_read", getNonContiguousReads());
builder.field("cached_bytes_read", getCachedBytesRead());
builder.field("index_cache_bytes_read", getIndexCacheBytesRead());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we update the stats.yml tests with the new fields?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++ see 2003ec0

builder.field("cached_bytes_written", getCachedBytesWritten());
builder.field("direct_bytes_read", getDirectBytesRead());
builder.field("optimized_bytes_read", getOptimizedBytesRead());
Expand All @@ -278,6 +318,8 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
builder.field("large", getBackwardLargeSeeks());
builder.endObject();
}
builder.field("blob_store_bytes_requested", getBlobStoreBytesRequested());
builder.field("current_index_cache_fills", getCurrentIndexCacheFills());
}
return builder.endObject();
}
Expand All @@ -302,9 +344,12 @@ public boolean equals(Object other) {
&& Objects.equals(contiguousReads, stats.contiguousReads)
&& Objects.equals(nonContiguousReads, stats.nonContiguousReads)
&& Objects.equals(cachedBytesRead, stats.cachedBytesRead)
&& Objects.equals(indexCacheBytesRead, stats.indexCacheBytesRead)
&& Objects.equals(cachedBytesWritten, stats.cachedBytesWritten)
&& Objects.equals(directBytesRead, stats.directBytesRead)
&& Objects.equals(optimizedBytesRead, stats.optimizedBytesRead);
&& Objects.equals(optimizedBytesRead, stats.optimizedBytesRead)
&& Objects.equals(blobStoreBytesRequested, stats.blobStoreBytesRequested)
&& currentIndexCacheFills == stats.currentIndexCacheFills;
}

@Override
Expand All @@ -313,8 +358,9 @@ public int hashCode() {
forwardSmallSeeks, backwardSmallSeeks,
forwardLargeSeeks, backwardLargeSeeks,
contiguousReads, nonContiguousReads,
cachedBytesRead, cachedBytesWritten,
directBytesRead, optimizedBytesRead);
cachedBytesRead, indexCacheBytesRead,
cachedBytesWritten, directBytesRead, optimizedBytesRead,
blobStoreBytesRequested, currentIndexCacheFills);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,6 @@ public static boolean isSearchableSnapshotStore(Settings indexSettings) {

public static final String CACHE_PREWARMING_THREAD_POOL_NAME = "searchable_snapshots_cache_prewarming";
public static final String CACHE_PREWARMING_THREAD_POOL_SETTING = "xpack.searchable_snapshots.cache_prewarming_thread_pool";

public static final String SNAPSHOT_BLOB_CACHE_INDEX = ".snapshot-blob-cache";
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ private CacheIndexInputStats randomCacheIndexInputStats() {
randomCounter(), randomCounter(),
randomCounter(), randomCounter(),
randomCounter(), randomCounter(),
randomCounter(), randomTimedCounter(),
randomTimedCounter(), randomTimedCounter());
randomCounter(), randomCounter(), randomTimedCounter(),
randomTimedCounter(), randomTimedCounter(),
randomCounter(), randomNonNegativeLong());
}

private Counter randomCounter() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ teardown:
- gte: { indices.docs.shards.0.0.files.0.cached_bytes_read.min: 0 }
- gte: { indices.docs.shards.0.0.files.0.cached_bytes_read.max: 0 }

- gte: { indices.docs.shards.0.0.files.0.index_cache_bytes_read.count: 0 }
- gte: { indices.docs.shards.0.0.files.0.index_cache_bytes_read.sum: 0 }
- gte: { indices.docs.shards.0.0.files.0.index_cache_bytes_read.min: 0 }
- gte: { indices.docs.shards.0.0.files.0.index_cache_bytes_read.max: 0 }

- gte: { indices.docs.shards.0.0.files.0.cached_bytes_written.count: 0 }
- gte: { indices.docs.shards.0.0.files.0.cached_bytes_written.sum: 0 }
- gte: { indices.docs.shards.0.0.files.0.cached_bytes_written.min: 0 }
Expand Down Expand Up @@ -203,6 +208,13 @@ teardown:
- gte: { indices.docs.shards.0.0.files.0.backward_seeks.large.min: 0 }
- gte: { indices.docs.shards.0.0.files.0.backward_seeks.large.max: 0 }

- gte: { indices.docs.shards.0.0.files.0.blob_store_bytes_requested.count: 0 }
- gte: { indices.docs.shards.0.0.files.0.blob_store_bytes_requested.sum: 0 }
- gte: { indices.docs.shards.0.0.files.0.blob_store_bytes_requested.min: 0 }
- gte: { indices.docs.shards.0.0.files.0.blob_store_bytes_requested.max: 0 }

- gte: { indices.docs.shards.0.0.files.0.current_index_cache_fills: 0 }

- do:
searchable_snapshots.stats:
index: "d*"
Expand Down
Loading