This is an automated email from the ASF dual-hosted git repository.

gerlowskija pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/main by this push:
     new d915b840fbb SOLR-18551: Prevent mmap leak in IndexFetcher (#5173)
d915b840fbb is described below

commit d915b840fbb5d5aa5c88e9ef1814bbefa123841e
Author: Jason Gerlowski <[email protected]>
AuthorDate: Mon Nov 9 15:46:22 2026 -0500

    SOLR-18551: Prevent mmap leak in IndexFetcher (#5173)
---
 .../unreleased/SOLR-18551-avoid-mmap-leak-in-indexfetcher.yml  | 10 ++++++++++
 solr/core/src/java/org/apache/solr/handler/IndexFetcher.java   | 10 +++++++---
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git 
a/changelog/unreleased/SOLR-18551-avoid-mmap-leak-in-indexfetcher.yml 
b/changelog/unreleased/SOLR-18551-avoid-mmap-leak-in-indexfetcher.yml
new file mode 100644
index 00000000000..c8e30f401e4
--- /dev/null
+++ b/changelog/unreleased/SOLR-18551-avoid-mmap-leak-in-indexfetcher.yml
@@ -0,0 +1,10 @@
+title: >
+  Fix mmap and virtual-memory leak in IndexFetcher
+type: fixed
+authors:
+  - name: Jason Gerlowski
+links:
+  - name: SOLR-18551
+    url: https://issues.apache.org/jira/browse/SOLR-18551
+  - name: Lucene Bug Report
+    url: https://github.com/apache/lucene/issues/15068
diff --git a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java 
b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
index a71366d7dbb..e31e8284eb3 100644
--- a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
+++ b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
@@ -1331,12 +1331,16 @@ public class IndexFetcher {
   }
 
   /**
-   * Returns true if the file exists (can be opened), false if it cannot be 
opened, and (unlike
-   * Java's File.exists) throws IOException if there's some unexpected error.
+   * Returns true if the file exists (as judged by a length check not throwing 
an error) and false
+   * otherwise.
+   *
+   * @throws IOException in the case of any unexpected (non "not found") I/O 
error
    */
   private static boolean slowFileExists(Directory dir, String fileName) throws 
IOException {
     try {
-      dir.openInput(fileName, IOContext.DEFAULT).close();
+      // We don't care about the length, just the existence check that will 
occur implicitly when
+      // checking length.
+      dir.fileLength(fileName);
       return true;
     } catch (NoSuchFileException | FileNotFoundException e) {
       return false;

Reply via email to