lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hoss...@apache.org
Subject lucene-solr:branch_7x: SOLR-9120: Reduce log level for inconsequential NoSuchFileException that LukeRequestHandler may encounter
Date Thu, 09 Nov 2017 17:48:40 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/branch_7x 0f4604d03 -> e0455440f


SOLR-9120: Reduce log level for inconsequential NoSuchFileException that LukeRequestHandler
may encounter

(cherry picked from commit 15fe53e10be74a0c953c4e0fac6815798cf66772)


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/e0455440
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/e0455440
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/e0455440

Branch: refs/heads/branch_7x
Commit: e0455440fe241477f9a269926a7a710e538074e2
Parents: 0f4604d
Author: Chris Hostetter <hossman@apache.org>
Authored: Thu Nov 9 09:53:22 2017 -0700
Committer: Chris Hostetter <hossman@apache.org>
Committed: Thu Nov 9 09:53:41 2017 -0700

----------------------------------------------------------------------
 solr/CHANGES.txt                                |  2 ++
 .../solr/handler/admin/LukeRequestHandler.java  | 32 ++++++++++++++------
 2 files changed, 25 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e0455440/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 7259596..48be91b 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -135,6 +135,8 @@ Other Changes
 * SOLR-11610: Refactored payload handling to use lucene's PayloadDecoder
   framework (Alan Woodward)
 
+* SOLR-9120: Reduce log level for inconsequential NoSuchFileException that LukeRequestHandler
may encounter (hossman)
+
 ==================  7.1.0 ==================
 
 Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e0455440/solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java
index 20fb71a..b2d8181 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java
@@ -17,6 +17,7 @@
 package org.apache.solr.handler.admin;
 
 import java.io.IOException;
+import java.nio.file.NoSuchFileException;
 import java.lang.invoke.MethodHandles;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -581,7 +582,7 @@ public class LukeRequestHandler extends RequestHandlerBase
     IndexCommit indexCommit = reader.getIndexCommit();
     String segmentsFileName = indexCommit.getSegmentsFileName();
     indexInfo.add("segmentsFile", segmentsFileName);
-    indexInfo.add("segmentsFileSizeInBytes", getFileLength(indexCommit.getDirectory(), segmentsFileName));
+    indexInfo.add("segmentsFileSizeInBytes", getSegmentsFileLength(indexCommit));
     Map<String,String> userData = indexCommit.getUserData();
     indexInfo.add("userData", userData);
     String s = userData.get(SolrIndexWriter.COMMIT_TIME_MSEC_KEY);
@@ -605,15 +606,28 @@ public class LukeRequestHandler extends RequestHandlerBase
   }
 
 
-
-  private static long getFileLength(Directory dir, String filename) {
+  /**
+   * <p>A helper method that attempts to determine the file length of the the segments
file for the 
+   * specified IndexCommit from it's Directory.
+   * </p>
+   * <p>
+   * If any sort of {@link IOException} occurs, this method will return "-1" and swallow
the exception since 
+   * this may be normal if the IndexCommit is no longer "on disk".  The specific type of
the Exception will 
+   * affect how severely it is logged: {@link NoSuchFileException} is considered more "acceptible"
then other 
+   * types of IOException which may indicate an actual problem with the Directory.
+   */
+  private static long getSegmentsFileLength(IndexCommit commit) {
     try {
-      return dir.fileLength(filename);
-    } catch (IOException e) {
-      // Whatever the error is, only log it and return -1.
-      log.warn("Error getting file length for [{}]", filename, e);
-      return -1;
-    }
+      return commit.getDirectory().fileLength(commit.getSegmentsFileName());
+    } catch (NoSuchFileException okException) {
+      log.debug("Unable to determine the (optional) fileSize for the current IndexReader's
segments file because it is "
+                + "no longer in the Directory, this can happen if there are new commits since
the Reader was opened",
+                okException);
+    } catch (IOException strangeException) {
+      log.warn("Ignoring IOException wile attempting to determine the (optional) fileSize
stat for the current IndexReader's segments file",
+               strangeException);
+    }
+    return -1;
   }
 
   /** Returns the sum of RAM bytes used by each segment */


Mime
View raw message