|
21 | 21 | import org.elasticsearch.common.collect.Tuple; |
22 | 22 | import org.elasticsearch.common.io.Channels; |
23 | 23 | import org.elasticsearch.common.lease.Releasable; |
24 | | -import org.elasticsearch.common.util.concurrent.EsExecutors; |
25 | 24 | import org.elasticsearch.index.snapshots.blobstore.BlobStoreIndexShardSnapshot.FileInfo; |
26 | 25 | import org.elasticsearch.index.snapshots.blobstore.SlicedInputStream; |
27 | 26 | import org.elasticsearch.index.store.BaseSearchableSnapshotIndexInput; |
@@ -252,28 +251,18 @@ protected void readInternal(ByteBuffer b) throws IOException { |
252 | 251 | directory.putCachedBlob(fileInfo.physicalName(), indexCacheMiss.v1(), content); |
253 | 252 | return indexCacheMissLength; |
254 | 253 | }, (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. |
258 | 258 | 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", |
260 | 260 | from, |
261 | 261 | to, |
262 | 262 | CachedBlobContainerIndexInput.this |
263 | 263 | ); |
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()); |
277 | 266 | } |
278 | 267 |
|
279 | 268 | final int bytesRead = populateCacheFuture.get(); |
|
0 commit comments