You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
During prewarming of a Lucene file a CacheFile is acquired and
then locked for the duration of the prewarming, ie locked until all
the part of the file has been downloaded and written to cache on
disk. The locking (executed with CacheFile#fileLock()) is here to
prevent the cache file to be evicted while it is prewarming.
But holding the lock may take a while for large files, specially since
restoring snapshot files now respects the
indices.recovery.max_bytes_per_sec setting of 40mb (#58658),
and this can have bad consequences like preventing the CacheFile
to be evicted, opened or closed. In manual tests this bug slow
downs various requests like mounting a new searchable snapshot
index or deleting an existing one that is still prewarming.
This commit reduces the time the lock is held during prewarming so
that the read lock is only required when actively writing to the CacheFile.
Copy file name to clipboardExpand all lines: x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/index/store/cache/CachedBlobContainerIndexInput.java
+42-43Lines changed: 42 additions & 43 deletions
Original file line number
Diff line number
Diff line change
@@ -453,54 +453,54 @@ public void prefetchPart(final int part) throws IOException {
453
453
454
454
try {
455
455
finalCacheFilecacheFile = getCacheFileSafe();
456
-
try (Releasableignored = cacheFile.fileLock()) {
457
-
458
-
finalTuple<Long, Long> range = cacheFile.getAbsentRangeWithin(partRange.v1(), partRange.v2());
459
-
if (range == null) {
460
-
logger.trace(
461
-
"prefetchPart: part [{}] bytes [{}-{}] is already fully available for cache file [{}]",
462
-
part,
463
-
partRange.v1(),
464
-
partRange.v2(),
465
-
cacheFileReference
466
-
);
467
-
return;
468
-
}
469
-
470
-
finallongrangeStart = range.v1();
471
-
finallongrangeEnd = range.v2();
472
-
finallongrangeLength = rangeEnd - rangeStart;
473
456
457
+
finalTuple<Long, Long> range = cacheFile.getAbsentRangeWithin(partRange.v1(), partRange.v2());
458
+
if (range == null) {
474
459
logger.trace(
475
-
"prefetchPart: prewarming part [{}] bytes [{}-{}] by fetching bytes [{}-{}] for cache file [{}]",
460
+
"prefetchPart: part [{}] bytes [{}-{}] is already fully available for cache file [{}]",
0 commit comments