You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ab...@apache.org on 2017/11/09 21:19:53 UTC
[47/50] [abbrv] lucene-solr:jira/solr-11285-sim: SOLR-9120: Reduce
log level for inconsequential NoSuchFileException that LukeRequestHandler may
encounter
SOLR-9120: Reduce log level for inconsequential NoSuchFileException that LukeRequestHandler may encounter
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/15fe53e1
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/15fe53e1
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/15fe53e1
Branch: refs/heads/jira/solr-11285-sim
Commit: 15fe53e10be74a0c953c4e0fac6815798cf66772
Parents: 946ec9d
Author: Chris Hostetter <ho...@apache.org>
Authored: Thu Nov 9 09:53:22 2017 -0700
Committer: Chris Hostetter <ho...@apache.org>
Committed: Thu Nov 9 09:53:22 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/15fe53e1/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 28abb89..fdfb738 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -153,6 +153,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/15fe53e1/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 */