Skip to content

Commit f06e0ae

Browse files
committed
Try to fill the cache miss rather than immediately failing
1 parent 1b459ae commit f06e0ae

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/index/store/cache/CachedBlobContainerIndexInput.java

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import org.elasticsearch.common.collect.Tuple;
2222
import org.elasticsearch.common.io.Channels;
2323
import org.elasticsearch.common.lease.Releasable;
24-
import org.elasticsearch.common.util.concurrent.EsExecutors;
2524
import org.elasticsearch.index.snapshots.blobstore.BlobStoreIndexShardSnapshot.FileInfo;
2625
import org.elasticsearch.index.snapshots.blobstore.SlicedInputStream;
2726
import org.elasticsearch.index.store.BaseSearchableSnapshotIndexInput;
@@ -252,28 +251,18 @@ protected void readInternal(ByteBuffer b) throws IOException {
252251
directory.putCachedBlob(fileInfo.physicalName(), indexCacheMiss.v1(), content);
253252
return indexCacheMissLength;
254253
}, (channel, from, to, progressUpdater) -> {
255-
// normally doesn't happen, we're already obtaining a range covering all cache misses above, but this
256-
// can happen if the real populateAndRead call already failed to obtain this range of the file. In that
257-
// case, we don't retry, we simply fail to populate the index cache.
254+
// Normally doesn't happen, we're already obtaining a range covering all cache misses above, but theoretically
255+
// possible in the case that the real populateAndRead call already failed to obtain this range of the file. In that
256+
// case, try and fill just the cache miss from the blob store because there may be other reads waiting on this
257+
// range.
258258
logger.debug(
259-
"failed to fill index cache miss [{}-{}] of {} due to earlier failure",
259+
"directly filling index cache miss [{}-{}] of {} due to earlier failure",
260260
from,
261261
to,
262262
CachedBlobContainerIndexInput.this
263263
);
264-
throw new IOException(
265-
"failed to fill index cache miss ["
266-
+ from
267-
+ "-"
268-
+ to
269-
+ "] of ["
270-
+ CachedBlobContainerIndexInput.this
271-
+ "] due to earlier failure"
272-
);
273-
},
274-
EsExecutors.newDirectExecutorService() // if ranges are still missing, fail immediately, so no need to fork
275-
);
276-
264+
writeCacheFile(channel, from, to, progressUpdater);
265+
}, directory.cacheFetchAsyncExecutor());
277266
}
278267

279268
final int bytesRead = populateCacheFuture.get();

0 commit comments

Comments
 (0)